PEP 255: Simple Generators

Neil Schemenauer nas at python.ca
Thu Jun 21 16:44:45 EDT 2001


Glyph Lefkowitz wrote:
> Generators solve *some* problems for which synchronous execution is
> desirable, but not others.  They change the semantics of function
> definition (despite the BDFL's pronouncement, my favorite piece of python
> zen is still "explicit is better than implicit" ^_^).  They add a keyword.  
> They do not fill my needs, or the needs of anyone working with simulation
> code, network dispatching, or massively parallel computing; whereas the
> simpler solutions which *do not* add a keyword and *do not* change the
> semantics of function definition can fill the needs of a far greater
> group, as well as the same set that would require generators.

PEP 255 is not intended to solve everyone's problems.  It is an
attempt at doing _something_ useful.  Is it better to have
generators in Python 2.2 or should we wait indefinately for
microthreads?  Even if we do get microthreads I still see the
extra syntax being useful.  Have you ever tried implementing
generators using Stackless's continuation primitives?  How would
you explain to new users what those magic functions do?

> Stackless is problematic, but I think that an implementation
> similiar to that of generators could give us microthreads.
> When I get back from vacation I'll write up a PEP; if you'd
> like to give me a hand, feel free to drop me an email :)

This would indeed be great news.  I've spent quite a bit of time
thinking about this and the stackless approach is best solution I
can think of.

  Neil




More information about the Python-list mailing list