Re: genexp performance problem?



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 achieve the same speed.

hint: how many times do the interpreter have to look up the names "int"
and "L" in the two examples ?

</F>

.



Relevant Pages

  • Re: Examples of SQL anomalies?
    ... Thanks for the hint, but the behaviour of the set functions indeed ... seems to be a bit strange ...
    (comp.databases.theory)
  • Re: [opensuse] Tearing down connections too fast
    ... That also seemed strange and I've found a hint it may be buggy here: ... "In TCP flag terms it's the equivalent of setting ACK, ...
    (SuSE)
  • Re: Whos been here the longest? (sort of FAO Rowland)
    ... >> hint: at Jul 98, ... > Forgive me if I sound cynical, but the only motivation behind this ... > thread seems to convince everyone reading it that you're an old-timer ... Which is strange, because old-timers tend not to feel any need to ...
    (uk.comp.sys.mac)
  • Re: what dose the word firmament mean
    ... This seems a very strange place to ask. ... Here's a hint: If you go to www.google.com and enter the line ... define: firmament ... please post all follow-ups to the newsgroup so ...
    (microsoft.public.word.docmanagement)
  • Re: Math whiz celebrates birthday
    ... L'il Helen dropped the hint when responding to Brady: ... One of mine was that you survived having all those strange people in your ...
    (alt.fan.letterman)