genexp performance problem?

Giovanni Bajo noway at sorry.com
Tue May 30 20:41:22 EDT 2006


Hello,

I found this strange:

python -mtimeit "sum(int(L) for L in xrange(3000))"
100 loops, best of 3: 5.04 msec per loop

python -mtimeit "import itertools; sum(itertools.imap(int, xrange(3000)))"
100 loops, best of 3: 3.6 msec per loop

I thought the two constructs could achieve the same speed.
-- 
Giovanni Bajo





More information about the Python-list mailing list