Numba Slows Down My Program Instead Of Speeding It Up
I came across a piece of code which did the job I wanted it to do a lot quicker than my original code did. However, unlike my original code this one is slowed down by the numba jit
Solution 1:
You have to adopt your code for jit-compiling:
@numba.njit
def sum_factors(n):
result = 1
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
result += i + n//i
return result
def amicable_pair(number):
result = []
for x in range(1,number+1):
y = sum_factors(x)
if sum_factors(y) == x and x != y:
result.append(tuple(sorted((x,y))))
return set(result)
print(amicable_pair(100000))
Post a Comment for "Numba Slows Down My Program Instead Of Speeding It Up"