[Python-ideas] Revised revised revised PEP on yield-from

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Feb 14 02:54:15 CET 2009

Raymond Hettinger wrote:

> Are there any use cases that warrant all this complexity?

Have you read the latest version of the Rationale?
I've tried to explain more clearly where I'm coming

As for real-world use cases, I've seen at least two
frameworks that people have come up with for using
generators as threads, where you make calls by
writing things like

    result = yield Call(f(x, y))

There is a "driver" at the top that's maintaining a
stack of generators and managing all the plumbing, so
that you can pretend the above statement is just doing
the same as

   result = f(x, y)

except that f is suspendable.

So some people *are* actually doing this sort of thing in
real life, in a rather ad-hoc way. My proposal would
standardise and streamline it, and make it more efficient.

It would also free up the values being passed in and
out of the yields so you can use them for your own
purposes, instead of using them to implement the
coroutine machinery.


More information about the Python-ideas mailing list