wrapping yield ?

Duncan Booth duncan at NOSPAMrcp.co.uk
Fri Sep 13 09:01:15 EDT 2002

"Michael Sparks" <Michael.Sparks at rd.bbc.co.uk> wrote in
news:alsg06$3e2$1 at nntp0.reith.bbc.co.uk: 

> "Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
> news:Xns9288759449799duncanrcpcouk at
>> The syntax wouldn't look quite so bad if your function wasn't
>> returning a value.
> Problem is, it would in most situations, also I'm trying to keep the
> number of generators to a minimum whilst a lower overhead than things
> like threads and processes if I had several 10s of thousands going,
> keeping throughput up may become an issue. (Hence the reason for
> wanting the functions called part of the same generator rather than a
> separate, extra one) 

Don't forget that iterating with a generator is *much* more efficient than 
calling a Python functions thousands of times.

Python has a big overhead on each function call, but you only pay that 
overhead when you first call a generator and the subsequent iterations have 
virtually no overhead at all. 

Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

More information about the Python-list mailing list