PEP 255: Simple Generators

Guido van Rossum guido at python.org
Thu Jun 21 09:09:38 EDT 2001


Glyph Lefkowitz <glyph at twistedmatrix.com> writes:

> Generators a-la PEP 255 seem like a *very* bad idea to me.
> 
> Generators can be implemented through continuations (as shown in
> Stackless) or through microthreads (as shown in the various previous
> implementations of generators which use *real* threads cooperatively).

Yes, as the PEP says.

> Neither microthreads nor continuations are implementable through
> generators.  I believe that generators (as described in PEP 255) are a
> merely a convenience, but real cooperative multithreading could be very
> useful and we would get generators *for free*.
> 
> While I am heavily in support of stackless being integrated for many
> reasons, I can understand the unfavorable sentiments that some harbor
> towards continuations.  They can be nastily abused.  They are
> confusing.  They interact very poorly with operator overloading and
> exception handling.

It has nothing to do with "unfavorable sentiments".  It has to do with
the practicality of getting it implemented.  Everything else you wrote
would be relevant if there was a chance of getting Stackless
implemented in core Python any time soon.  But it's not going to
happen -- Stackless has too many issues that would need to be resolved
one way or another; it too has many seemingly arbitrary restrictions
that make it impossible to just adopt Christian Tismer's code.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list