[Python-Dev] async/await in Python; v2 (original) (raw)
Victor Stinner victor.stinner at gmail.com
Wed Apr 22 22:46:56 CEST 2015
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing <greg.ewing canterbury.ac.nz> writes:
I still don't like the idea of hijacking the generic term "coroutine" and using it to mean this particular type of object.
There are only two hard things in Computer Science: cache invalidation
and naming things.
-- Phil Karlton
:-)
When reviewing Yury's PEP, I read Wikipedia's article of Coroutine because I didn't know if a "coroutine" is something new in Python nor if it was well defined.
https://en.wikipedia.org/wiki/Coroutine
Answer: it's not new, and it's implemented in many languages, and it's well defined.
But coroutines are not always directly called "coroutines" in other programming languages.
Using a custom name like "cofunction" may confuse users coming from other programming languages. I prefer to keep "coroutine", but I agree that we should make some effort to define the different categories of "Python coroutines". Well, there are two kind kinds of coroutines:
(A) asyncio coroutine in Python 3.4: use yield from, yield denied, decorated with @asyncio.coroutine (B) PEP 492 coroutine in Python 3.5: use await, yield & yield from denied, function definition prefixed by "async"
Yury proposed "generator-based coroutine for the kind (A). Maybe not a great name, since we can learn in the PEP 492 that the kind (B) is also (internally) based on generators.
I don't think that we should use distinct names for the two kinds in common cases. But when we need to clearly use distinct names, I propose the following names:
Kind (A):
- "yield-from coroutines" or "coroutines based on yield-from"
- maybe "asyncio coroutines"
- "legacy coroutines"?
Kind (B):
- "awaitable coroutines" or "coroutines based on await"
- "asynchronous coroutine" to remember the "async" keyword even if it sounds wrong to repeat that a coroutine can be interrupted (it's almost the definition of a coroutine, no?)
- or just "asynchronous function" (coroutine function) & "asynchronous object" (coroutine object)
Victor
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]