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
_____________________________________________ Metakit mailing list - [email protected] http://www.equi4.com/mailman/listinfo/metakit
