This answer is based on this brilliant solution Fast Python Solution

I found there is still room to improve it.

Use 1, 0 instead of True, False, it could be a little faster.

```
class Solution:
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
if n < 2:
return 0
s = [1] * n
s[0] = s[1] = 0
for i in range(2, int(n ** 0.5) + 1):
if s[i] == 1:
s[i * i:n:i] = [0] * len(s[i * i:n:i])
return sum(s)
```