In a normal njit function setting error_model=”numpy” does exactly this. There are also significant speedups possible by setting this option. So: @njit(error_model=”numpy”) If you are wandering what Numba is, read more about Numba here. It’s a really cool thing, I highly recommend getting familiar with it.
This example is perfect for showing how fast Numba can be with when put right with Nopython mode (@jit(nopython=True) or@njit) import numpy as np import numba as nb from numba import jit, njit import time start_time = time.time() # @nb.jit(nb.float64[:](nb.float64[:])) @njit def f(arr): res = np.zeros(len(arr)) for i in range(len(arr)): res[i] = (arr[i]) ** 2 … Read more