I'm trying to compare numba and pure python using the basic example and I'm getting odd results.
This is the numba example:
from numba import jit
from numpy import arange
from time import time
# jit decorator tells Numba to compile this function.
# The argument types will be inferred by Numba when function is called.
@jit
def sum2d(arr):
M, N = arr.shape
result = 0.0
for i in range(M):
for j in range(N):
result += arr[i,j]
return result
a = arange(9).reshape(3,3)
t = time()
print(sum2d(a))
print time() - t
This is the timing I'm getting with numba 0.0469660758972 seconds
And without numba I'm getting a faster result 9.60826873779e-05 seconds