[Python-ideas] x=(yield from) confusion [was:Yet another alternative name for yield-from]

Jim Jewett jimjjewett at gmail.com
Fri Apr 3 19:06:52 CEST 2009

On 4/2/09, Guido van Rossum <guido at python.org> wrote:
> On Thu, Apr 2, 2009 at 6:43 PM, Jim Jewett <jimjjewett at gmail.com> wrote:
>> yield from *as an expression* only really makes sense if the generator
>> is sending useful information *both* ways.  I can understand that sort
>> of generator only while reading the PEP; the code smell is strong
>> enough that I forget it by the next day.

> Read Dave Beazley's coroutines tutorial (dabeaz.com/couroutines) and
> check out the contortions in the scheduler to support subgenerators
> (Part 8).

I have.  I still don't see it really helping with anything except
maybe (in http://dabeaz.com/coroutines/pyos8.py) the Task.run method.

Even there, I don't see an expression form helping very much.  Passing
through the intermediate yields could be nice, but a statement can do
that.  Grabbing a separate final value could change the "try ...
except StopIteration" into an "x=yield from", but ... I'm not sure
that could really work, because I don't see how all the code inside
the try block goes away.  (It might go away if you moved that logic
from the task to the scheduler, but then the protocol seems to get
even more complicated, as the scheduler has to distinguish between
"I've used up this time slot", as well as "I have intermediate
results, but might be called again", and "I'm done".)


More information about the Python-ideas mailing list