generator expressions: performance anomaly?
Ola Natvig
ola.natvig at infosense.no
Tue Jan 18 08:21:18 EST 2005
Diez B. Roggisch wrote:
>> 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))
>
>
Would it be a bad solution to make that a list or tuple of ten
time.time() calls, you could also restrict what theese prebuilding
sequenses could contain, or perhaps try to prebuild them, and then fail
if it's impossible.
--
--------------------------------------
Ola Natvig <ola.natvig at infosense.no>
infoSense AS / development
More information about the Python-list
mailing list