stackless python

François Pinard pinard at iro.umontreal.ca
Mon Jul 8 18:42:51 EDT 2002


[Neil Schemenauer]

> François Pinard wrote:
> > (My main question, maybe already answered in there -- I did not check yet
> > -- is how one proceeds to `yield' from within a nest of function calls,
> > and to later kludge resuming the function nesting sequence on `.next()'.)

> You can't since only one stack frame is saved per generator.  That's why
> one of the reasons they are called simple generators (two others being
> ease of implementation and of understanding).  You probably want to look
> at stackless Python if you haven't already.

I'm aware of Stackless, of course, yet I prefer to stick to standard Python
if possible.  My need for "non-simple" generators is not at all serious
at this stage.  Since it has been in previous projects, it is likely to be
in future projects, and I merely wanted to foresee problems and solutions
in an informal way, while looking at Python generators.

Maybe one could find how to chain generators in the same way one nests
functions, with some idiomatic writing for moving back and forth along
the chain.  Most probably, I'll try a bit harder if I ever have a real,
immediate need. :-) Stackless is a always there, too!

Thanks for the help you provided already.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list