<pre><code>def prime_sieve(limit):
    prime = [True] * limit
    prime[0] = prime[1] = False

    for i, is_prime in enumerate(prime):
        if is_prime:
            yield i
            for n in range(i * i, limit, i):
                prime[n] = False
</code></pre>
<p><a href="http://codereview.stackexchange.com/a/150447/98493">http://codereview.stackexchange.com/a/150447/98493</a></p>

Graipher