[Python-ideas] The async API of the future: yield-from

Devin Jeanpierre jeanpierreda at gmail.com
Sat Oct 20 07:27:52 CEST 2012


On Fri, Oct 19, 2012 at 10:44 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> If I wrote a library intended for serious use, the end user
> probably wouldn't write either of those. Instead he would
> write something like
>
>    yield from block(self.queue)
>
> and it would be an implementation detail of the library
> where abouts the 'yield' happened and whether it needed
> to send a value or not.

What's the benefit of having both "yield" and "yield from" as opposed
to just "yield"? It seems like an attractive nuisance if "yield" works
but doesn't let the function have implementation details and wait for
more than one thing or somesuch.

With the existing generator-coroutine decorators (monocle,
inlineCallbacks), there is no such trap. "yield foo()" will work no
matter how many things foo() will wait for.

My understanding is that the only benefit we get here is nicer
tracebacks. I hope there's more.

-- Devin



More information about the Python-ideas mailing list