quemb.shared.helper.njit¶
- quemb.shared.helper.njit(f=None, *, nogil, **kwargs)¶
Type-safe jit wrapper that caches the compiled function
With this jit wrapper, you can actually use static typing together with numba. The crucial declaration is that the decorated function’s interface is preserved, i.e. mapping
FunctiontoFunction. Otherwise the following example would not raise a type error:@numba.njit def f(x: int) -> int: return x f(2.0) # No type error for numba < 0.68
While the same example, using this custom
njit()would raise a type error. Since numba 0.68,numba.njitis typed itself and also raises the type error, but this wrapper is kept because it also setscache=Trueby default.