[Metakit] Performance comparison Q

Jean-Claude Wippler jcw at equi4.com
Mon May 9 22:43:07 CEST 2005


Magnus Lie Hetland wrote:

>> result = sum(xrange(50000))
>
> I just did a simple experiment (using the timeit module) comparing
> the performance of sum(range(50000)) and sum(xrange(50000)), and the
> latter gave a speedup factor of about 2.2 on my computer... Also,
> allocating a list of size 50000 seems a bit wasteful just for
> computing this sum :)

The point is not the result (25000*49999 will get there a lot faster).

I'm trying to see how a list of values, iteration over it, and a  
simple integer operator work together in each particular language.

Don't quite see the same speedup for xrange, but as I said it is not  
the issue here for me.

-jcw



More information about the Metakit mailing list