On Thursday, Mar 17, 2005, at 17:49 America/Chicago, [EMAIL PROTECTED] wrote:
On my system, it took 415 seconds to generate a list of primes < 50,000If you only calculate y up to sqrt(x) you will see a dramatic time reduction:
using range, but only 386 seconds if I use the same code, but with xrange instead.
###
import math
big=50000
[x for x in xrange(2,big) if not [y for y in range(2,int(math.sqrt(x)+1)) if x%y==0]]
###
/c
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor