Alan Gauld, 16.04.2010 10:09:
Even the built in sum() will be faster than a while loop:

result = sum(range(1000000000))

although it still took 10 minutes on my PC.

Did you mean to say "minutes" or rather "seconds" here? And did you really mean to use "range" or rather "xrange" (or "range" in Py3)?

    sum(xrange(1000000000))

clearly runs in 12 seconds for me on Py2.6, whereas the same with "range" gives an error due to insufficient memory.

Stefan

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to