generator expressions: performance anomaly?

Diez B. Roggisch deetsNOSPAM at web.de
Tue Jan 18 08:18:21 EST 2005


>    lst = list(genexp)
>    tpl = tuple(genexp)
> 
> 
> Since in such cases the object is build in memory any way, I don't
> think it would be a problem of having them prebuilt in memory, or am
> I missing something?

Yes. Consider this:

lst = list(time.time() for i in xrange(10))
tpl = tuple(time.time() for i in xrange(10))


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list