time ./isprime2.8s:

#!/usr/bin/python

def isPrime(n):

if n == 2 or n == 3:

return 1

if n % 2 == 0 or n % 3 == 0:

return 0

i = 5

w = 2

while i*i <= n:

if n % i == 0:

return 0

i += w

w = 6 - w

return 1

primes = []

for i in range(1, 1000000):

if isPrime(i):

primes.append(i)

print primes

THE RANGE OF Y SHOULD BE (2, X/2) INSTEAD OF (2, X-1) FOR OPTIMIZED CODE