[Python-ideas] yiled-from restrictions [was: x=(yield from) confusion]

Jim Jewett jimjjewett at gmail.com
Thu Apr 9 18:54:41 CEST 2009

On 4/9/09, Jacob Holm <jh at improva.dk> wrote:
> Guido van Rossum wrote:
>> On Wed, Apr 8, 2009 at 7:52 PM, Jacob Holm <jh at improva.dk> wrote:

>>> Does storing it as part of the frame object count as "naturally in the
>>> stack frame"?

>> No, that's out too. My point is that I don't want to add *any* state
>> beyond what the user thinks of as the "normal" state in the frame
>> (i.e. local variables, where it is suspended, and the expression stack
>> and try-except stack). Nothing else.

Do you mean nothing user-visible, or do you really mean nothing, not
even as an implementation detail?

> 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.

Well, to do it efficiently anyhow... but it doesn't need to be
user-visible, which is why I asked for clarification.

> One final suggestion I have is to make yield-from raise a RuntimeError
> if used on a generator that already has a frame.

That would prevent priming the generator.  It would also prevent

"handled the header lines already; pass the data records off to a
different routine."


More information about the Python-ideas mailing list