[Python-ideas] Yield-From: Finalization guarantees

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 3 10:02:04 CEST 2009

Guido van Rossum wrote:
> I wonder if we shouldn't back off from the
> refactoring use case a bit and instead just ponder the different types
> of code you can write using generators. There's the traditional "pull"
> style (iterators), "push" style (like the averaging example), and then
> there are "tasks".

I'm not sure how to respond to that, because the whole
issue at stake is whether a certain kind of refactoring
should be considered legal. It's orthogonal to whether
you're using push/pull/task style generators.

> (Have you read Dave Beazley's couroutines tutorial
> yet? Or am I the only one who likes it? :-)

Yes, I've read it, and I quite like it too.

As for where yield-from fits into it, mainly it would
be in section 8, where it would eliminate the need for
trampolining to handle calls/returns.

It doesn't directly help with pipelines of coroutines,
because you're processing the values at each step
rather than just passing them through. But it would
enable a single step of the pipeline to be spread over
more than one function more easily (something he refrains
from doing at that stage in the tutorial, because it
would require the trampolining technique that he doesn't
develop until later).


More information about the Python-ideas mailing list