[Python-ideas] PEP 380 alternative: A yielding function

Anders J. Munch 2010 at jmunch.dk
Thu Jul 29 14:06:37 CEST 2010


Greg Ewing wrote:
 > Anders J. Munch wrote:
 >
 >> Right, yield_if_true is a regular function, that's the whole point.
 >
 > What if it needs to call yield_() more than once? If it's
 > just a regular function, then it has no ability to be
 > suspended at the point of yield and resumed.

I meant a regular function from the point of view of the compiler.
The implementation would be special, of course.  And therein lies the
rub: It's unimplementable in CPython, alas.  It could work in an
implementation with a non-recursive eval loop, but if I'm not much
mistaken, CPython recurses the eval loop even for a pure-Python
function call.

regards, Anders




More information about the Python-ideas mailing list