[EMAIL PROTECTED] wrote:
Quoting Gregor Lingl <[EMAIL PROTECTED]>:
[x for x in range(2,100) if not [y for y in range(2,x) if x%y==0]]
Heh. That's quite neat.
I can only offer one suggestion --- if you replace range with xrange, you get a
small speed improvement.
eg: On my system, it took 415 seconds to generate a list of primes < 50,000
using range, but only 386 seconds if I use the same code, but with xrange
instead.
What about using something like range(2, math.sqrt(x)) instead?
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor