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

Greg Ewing greg at cosc.canterbury.ac.nz
Tue Aug 24 04:50:19 CEST 2004


> 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.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list