[Python-Dev] Re: Minimal 'stackless' PEP using generators?

Brett C. bac at OCF.Berkeley.EDU
Tue Aug 24 06:56:13 CEST 2004


Greg Ewing wrote:

>>it would be
>>equivalent as if every "val = g2.next()" in g1 was rewritten:
>>
>>    val = g2.next()
>>    if isinstance(val, magic.Cooperate):
>>        yield val
> 
> 
> Something bothers me about that proposal, and I think it's this: it
> would mean that generators are no longer simply a particular technique
> for implementing iterators, but would have special powers that other
> iterators don't have. Unless recognising the magic Cooperate value and
> doing the right thing were made part of the iterator protocol, and all
> iterators were expected to do the right thing with it, which would be
> a big imposition.
> 

I agree with Greg and the other comments on wanting to keep generators 
simple.  Part of the beauty of generators is the are brain-dead simple 
to use while still being handy as hell.  Playing with them to add the 
ability to play asynchronous stuff doesn't seem right.

I would rather see full-blown coroutines for Python 3000 to deal with 
this somehow.

-Brett


More information about the Python-Dev mailing list