I am trying to use numpy.linalg.inv
in some code which is then jitted with @numba.njit
. However, I notice that the code does not get significantly faster. Moreover, when I run the same code several times, the time varies drastically (like 4 times different). I wrote some toy code to check whether numpy.linalg.inv
gets faster at all with numba:
def matrinv(M):
res = np.linalg.inv(M)
return res
@njit
def matrinv_fast(M):
res = np.linalg.inv(M)
return res
The running times are almost the same (like 40 ms vs 35 ms). Is it because the existing numpy functions are already precompiled, and numba cannot get them faster? Or I am doing something wrong?