quemb.shared.helper.njit¶
- quemb.shared.helper.njit(f=None, **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
Function
toFunction
. 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=True
by default.