Comments are moderated. It may take a few minutes before your comment appears.
Markdown is supported in your comments.
def primes(p_cache=[2]):
for i in p_cache:
yield i
for i in count(p_cache[-1] + 1):
sqr = int(i**0.5) + 1
if all(i%p for p in takewhile(lambda x: x<sqr, p_cache)):
p_cache.append(i)
yield i