[Python-Dev] Implementing PEP 342 (was Re: Withdrawn PEP 288 and thoughts on PEP 342)

Phillip J. Eby pje at telecommunity.com
Sat Jun 18 02:54:22 CEST 2005


At 08:03 PM 6/16/2005 -0700, Guido van Rossum wrote:
>I do like "continue EXPR" but I have to admit I haven't even tried to
>come up with examples -- it may be unnecessary. As Phillip says, yield
>expressions and g.next(EXPR) are the core -- and also incidentally
>look like they will cause the most implementation nightmares. (If
>someone wants to start implementing these two now, go right ahead!)

FYI, I've started work on a patch.  I've got argument passing into 
generators working, and compiling of parenthesized yield expressions, in 
both the C and Python compilers (although the output of the compiler 
package isn't tested yet).  I haven't implemented no-argument yields yet, 
either, or unparenthesized yields on the far RHS of an assignment.  I do 
plan to implement throw() as part of the same patch.  Much of what remains 
is expanding the test suite and writing documentation, though.

It turns out that making 'next(EXPR)' work is a bit tricky; I was going to 
use METH_COEXIST and METH_VARARGS, but then it occurred to me that 
METH_VARARGS adds overhead to normal Python calls to 'next()', so I 
implemented a separate 'send(EXPR)' method instead, and left 'next()' a 
no-argument call.  Whether this is the way it should really work or not is 
a PEP discussion, of course, but it does seem to me that making send(ob) 
and throw(typ,val,tb) separate methods from the iterator protocol is a 
reasonable thing to do.

Anyway, the patch isn't ready yet, but I hope to be able to post something 
for review before the weekend is out.



More information about the Python-Dev mailing list