code: def _eratosthenes():
      
      d = {}  # map each composite integer to its first-found prime factor
      for q in count(2):  # q gets 2, 3, 4, 5, ... ad infinitum
          p = d.pop(q, None)
          if p is None:
              # q not a key in D, so q is prime, therefore, yield it
              yield q
              # mark q squared as not-prime (with q as first-found prime factor)
              d[q * q] = q
          else:
              # let x <- smallest (N*p)+q which wasn't yet known to be composite
              # we just learned x is composite, with p first-found prime factor,
              # since p is the first-found prime factor of q -- find and mark it
              x = p + q
              while x in d:
                  x += p
              d[x] = p
docs: Yields the sequence of prime numbers via the Sieve of Eratosthenes.