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
While the same example, using this custom
njit()would raise a type error.In addition to type safety, this wrapper also sets
cache=Trueby default.