[Python-Dev] PEP 492: What is the real goal?

Guido van Rossum guido at python.org
Thu Apr 30 22:09:45 CEST 2015


It is spelled "Raymond Luxury-Yacht", but it's pronounced "Throatwobbler
Mangrove". :-)

I am actually fine with calling a function defined with "async def ..." an
async function, just as we call a function containing "yield" a generator
function.

However I prefer to still use "coroutine" to describe the concept
implemented by async functions. *Some* generator functions also implement
coroutines; however I would like to start a movement where eventually we'll
always be using async functions when coroutines are called for, dedicating
generators once again to their pre-PEP-342 role of a particularly efficient
way to implement iterators.

Note that I'm glossing over the distinction between yield and yield-from
here; both can be used to implement the coroutine pattern, but the latter
has some advantages when the pattern is used to support an event loop: most
importantly, when using yield-from-style coroutines, a coroutine can use
return to pass a value directly to the stack frame that is waiting for its
result. Prior to PEP 380 (yield from), the trampoline would have to be
involved in this step, and there was no standard convention for how to
communicate the final result to the trampoline; I've seen "returnValue(x)"
(Twisted inlineCallbacks), "raise ReturnValue(x)" (Google App Engine NDB),
"yield Return(x)" (Monocle) and I believe I've seen plain "yield x" too
(the latter two being abominations in my mind, since it's unclear whether
the generator is resumed after s value-returning yield).

While yield-from was an improvement over plain yield, await is an
improvement over yield-from. As with most changes to Python (as well as
natural evolution), an improvement often leads the way to another
improvement -- one that wasn't obvious before. And that's fine. If I had
laid awake worrying about the best way to spell async functions while
designing asyncio, PEP 3156 probably still wouldn't have been finished
today.

On Thu, Apr 30, 2015 at 12:40 PM, Antoine Pitrou <solipsis at pitrou.net>
wrote:

> On Thu, 30 Apr 2015 12:32:02 -0700
> Guido van Rossum <guido at python.org> wrote:
> >
> > No, this is the name we've been using since PEP 342 and it's still the
> same
> > concept.
>
> The fact that all syntax uses the word "async" and not "coro" or
> "coroutine" hints that it should really *not* be called a coroutine
> (much less a "native coroutine", which both silly and a lie).
>
> Why not "async function"?
>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150430/d30e57c0/attachment.html>


More information about the Python-Dev mailing list