Giovanni Bajo wrote:
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
Giovanni Bajo wrote:
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
Giovanni Bajo wrote:
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
Fredrik Lundh wrote:
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
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 wrote:
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.
Delaney, Timothy (Tim) wrote:
python -mtimeit sum(int(L) for L in xrange(3000))
100 loops, best of 3: 6.76 msec per loop
python -mtimeit -s g = (int(L) for L in xrange(3000)) sum(g)
100 loops, best of 3: 1.09 usec per loop
The generator comprehension needs to create a new generator
Kent Johnson wrote:
Reusing the generator doesn't give a correct answer; after the first
sum() the generator is exhausted:
Duh - good point. I forgot it was returning a generator object, not
generator function.
Tim Delaney
--
http://mail.python.org/mailman/listinfo/python-list