Finding integer with the most natural dividers
It's not clear what you mean with &quot;natural dividers&quot;. Better specify that, show examples, and document allnums to say what it does. A better name would also help. For example allnums(6) returns only 1, despite having divisors 1, 2, 3 and 6. At the very least I'd expect answer 2 (for the divisors 2 and 3). So probably it's incorrect, but we can't even tell because you didn't say what exactly it's supposed to do.
Anyway, as usual it suffices to try divisors until the square root, not until half. If you find a divisor i of k, then don't just count that divisor but also count its partner divisor k/i. Unless that's the same.
And max can take an iterable and key.
So:
from math import isqrt

def divisors(k):
    &quot;&quot;&quot;Compute the number of k's divisors 1 &lt; divisor &lt; k.&quot;&quot;&quot;
    cnt = 0
    for i in range(2, isqrt(k) + 1):
        if k % i == 0:
            cnt += 2 - (k // i == i)
    return cnt

print(max(range(568023, 569231), key=divisors))

Takes about 0.1 seconds.