Answer by AJNeufeld for Further Optimizing a Segmented Sieve of Eratosthenes
Python 3.8 adds math.isqrt(). Using this, you can make a much less cryptic perfect square check:high == math.isqrt(high) ** 2Memory Optimization (speed too!)Using a list of Boolean flags:numbers =...
View ArticleFurther Optimizing a Segmented Sieve of Eratosthenes
I've implemented a Segmented Sieve of Eratosthenes that assumes each segment is about length \$ \sqrt{N}\$ for some upper limit \$N\$.I further optimized the function by skipping all the evens when...
View Article
More Pages to Explore .....