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

Jacob Holm jh at improva.dk
Fri Apr 10 10:06:12 CEST 2009

Guido van Rossum wrote:
> On Thu, Apr 9, 2009 at 5:35 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> Jacob Holm wrote:
>>> That rules out Gregs and my patches as well.  They both need extra state
>>> on the frame object to be able to implement yield-from in the first place.
>> But that state is obviously necessary in order to support
>> yield-from, and it goes away as soon as the yield-from
>> itself finishes.
> Another way to look at this is, "RETVAL = yield from EXPR" has an
> expansion into source code where all that state is kept as either a
> local variable or via the position in the code, and that's how we
> define the semantics. I don't believe Jacob's proposal (the one that
> doesn't require new syntax) works this way.

My proposal was to extend the lifetime of the yielded value until the 
yield expression returned, and to make that value available on the 
frame.  The "keep the value alive" part can easily be written as an 
expansion based on the existing yield semantics, and the "make it 
available on the frame" is similar to the need that yield-from has.  
That doesn't look all that different to me, but I'll let you be the 
judge of that.

- Jacob

More information about the Python-ideas mailing list