Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 11c25a4 commit 3a639bbCopy full SHA for 3a639bb
1 file changed
Doc/library/itertools.rst
@@ -822,12 +822,13 @@ which incur interpreter overhead.
822
def sieve(n):
823
"Primes less than n"
824
# sieve(30) --> 2 3 5 7 11 13 17 19 23 29
825
- data = bytearray([1]) * n
826
- data[:2] = 0, 0
+ data = bytearray((0, 1)) * (n // 2)
+ data[:3] = 0, 0, 0
827
limit = math.isqrt(n) + 1
828
for p in compress(range(limit), data):
829
- data[p*p : n : p] = bytearray(len(range(p*p, n, p)))
830
- return iter_index(data, 1)
+ data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))
+ data[2] = 1
831
+ return iter_index(data, 1) if n > 2 else iter([])
832
833
def flatten(list_of_lists):
834
"Flatten one level of nesting"
0 commit comments