On a 64-bit CPython 2.x,
all(i for i in xrange(2**63 - 1))
all(i for i in xrange(2**63))
overflows. See this explanation, and a workaround. I suggest rewriting this using an old-fashioned
With Python 3.x,
all(i for i in range(2**63))
You've implemented trial division. A more efficient algorithm is the sieve-of-eratosthenes, especially if you want to test multiple numbers for primality. However, the Sieve of Eratosthenes requires more memory, so you'll have to resort to some hacks to make it work for large numbers.
For truly large numbers, you'll have to implement more sophisticated algorithms.