I'm trying the following approach for generating primes:

```
primes = [2]
candidate = 3
MILLION = 1000000
while candidate < MILLION:
    if all(candidate % prime for prime in primes if prime**2 <= candidate):
        primes.append(candidate)
    candidate += 2

```

However, this is comparatively much slower than my previous code, where I wasn't using the [`all`](https://docs.python.org/2/library/functions.html#all) function, and was making the checks myself as below:

```
primes = [2]
candidate = 3
MILLION = 1000000
while candidate < MILLION:
    can_be_prime = True
    for p in primes:
        if p**2 > candidate:
            break
        elif candidate % p == 0:
            can_be_prime = False
            break
    if can_be_prime:
        primes.append(candidate)
    candidate += 2

```

While the second one gets over within 10 seconds, the first one takes forever to complete. Can someone help me understand why the first one starts outputting so slowly after the first 100000 numbers?