That's not the sieve of Eratosthenes
It's rather prime trial division.
Your filter for 2 lets 1/2 of all numbers through, your filter for 3 lets 2/3 of all remaining numbers through, etc. So 1/2 * 2/3 * 4/5 * 6/7 = 22% of all numbers make it through your filters for 2, 3, 5 and 7, so your filter for 11 will have to check 22% of all numbers. The real sieve of ...
Back to the roots - be lazier!
(Taking this in another direction than my first answer, and it's different/long enough that I don't want to mix them.)
We can vastly improve your approach by not eagerly adding filters and instead only adding filters up to the square root of the current candidate number. And I found an in my opinion neat way to do that. ...
Bonus points for coming up with something that is both "interesting" and "technically correct"; but that's about where it stops. It's certainly not fast.
Think about what's happening here: for every single call of eval or asmod, you're chaining another layer of filter - with a new function - on your generator. That simply won't scale. You'...
As mentioned by Marc, Since Python 3.8 you can use math.isqrt. This is faster. It is also guaranteed to be accurate when the size of the argument exceeds the number of bits of mantissa in a float.
sieve_arr = array('i', [True for _ in range(n+1)])
Your array is declared to hold 'i' values: integers. But you are trying to ...
Your sieve can be optimized further. Pull the case for i = 2 outside of the for loop and then change the for loop to only check odd indexes. Also use slice assignment instead of a nested loop. This code is 10x faster (<100ms to sieve primes to 1M compared to >1s for your sieve).
"""Sieve of Erathosthenes"&...
Agreed, this is not the Sieve of Eratosthenes. This is trial division by primes. (As long as you're doing trial division, you can do it slightly better, and only test up to the square root of the number.)
Replace the while loop, making it clearer and more pythonic: for test in num_list:
It is inefficient to delete from the middle of a list in python, which ...
op_count is declared in the global scope, pulled into the primes_goto local scope, but is never used. It may be deleted.
limitN and pr_count are declared in the global scope, but only ever used inside the primes_goto function. They may be removed from the global scope, and simply declared inside the primes_goto function....
You can use bitarray, this tends to be a little faster.
The code using bitarray is
from bitarray import bitarray
from math import sqrt, ceil, log
def primes_goto2(index: int):
prime_up_to = ceil(index * (log(index) + log(log(index)))) + 4
primes = bitarray(prime_up_to)
primes = primes = False