[Python-ideas] Yield-From: Finalization guarantees
Ron Adam
rrr at ronadam.com
Thu Mar 26 21:26:13 CET 2009
Greg Ewing wrote:
> Nick Coghlan wrote:
>
>> I'm not so sure about that - we don't do it for normal iteration, so why
>> would we do it for the new expression?
>
> Because of the inlining principle. If you inline a
> subgenerator, the result is just a single generator,
> and closing it finalizes the whole thing.
>
>> Since the main advantage that the new expression has over simple
>> iteration is delegating send() and throw() correctly, and I'm suggesting
>> that shared iterators and those two methods don't mix, perhaps this
>> whole issue can be set aside?
>
> Sounds good to me.
Just a thought...
If the subgenerator does not interact with the generator it is in after it
is started, then wouldn't it be as if it replaces the calling generator for
the life of the sub generator? So instead of in-lining, can it be thought
of more like switching-to another generator?
Ron
More information about the Python-ideas
mailing list