'Generate all prime numbers in the range [a, b).
Examples
>>> from sympy import sieve
>>> print([i for i in sieve.primerange(7, 18)])
[7, 11, 13, 17]'

def primerange(self, a, b):

    from sympy.functions.elementary.integers import ceiling
    a = max(2, int(ceiling(a)))
    b = int(ceiling(b))
    if (a >= b):
        return
    self.extend(b)
    i = self.search(a)[1]
    maxi = (len(self._list) + 1)
    while (i < maxi):
        p = self._list[(i - 1)]
        if (p < b):
            (yield p)
            i += 1
        else:
            return
