Python 1.6 The balanced language

Just van Rossum just at letterror.com
Thu Sep 7 08:46:06 EDT 2000


[ Generators ]

Tim Peters wrote:
> Right.  I imagine a PEP will be written eventually with all the gory
> details.  In brief, Python already allocates its own "stack frames" off the
> heap as just another kind of Python object, so the primary trick in
> implementing Icon-style generators with the current VM is simply to refrain
> from decrementing the frame's refcount at a return!  The frame object
> already contains (almost) all the state it needs to resume from where it
> left off.
> 
> This is indeed not general enough to support coroutines; the essential
> simplifying feature of an Icon-style generator is that it *always*
> "suspends" to whoever invoked it (and so, unlike a coroutine, does not
> *name* to whom it suspends); in this way it remains strictly stack-like; for
> people who like buzzwords <wink>, Knuth calls Icon-style generators
> "semi-coroutines"; I've sometimes, and with a bit of success, tried to call
> them "resumable functions" on comp.lang.python, to take away some of the
> mystery.  In a sense, they do for function-local control flow what C
> "static" does for function-local data:  preserves it "across
> calls/resumptions".

How would you spell resuming a suspended function?

Just



More information about the Python-list mailing list