numpy#
- mvpy.utilities.compile.numpy(*args: List[Any], nopython: bool = True, nogil: bool = True, fastmath: bool = True, cache: bool = True, disable: bool = False, **kwargs: Dict[str, Any]) Callable[source]#
Decorator that compiles a function with numba.jit, if available.
- Parameters:
- *argsList[Any]
Arguments to pass.
- nopythonbool, default=True
Default to pass to jit.
- nogilbool, default=True
Default to pass to jit.
- fastmathbool, default=True
Default to pass to jit.
- cachebool, default=True
Default to pass to jit.
- disablebool, default=False
Flag to allow disabling compilation (for debugging).
- **kwargsDict[str, Any]
Keyword arguments to pass.
- Returns:
- compiledCallable
Compiled function.
Examples
Let’s look at a very silly toy example: >>> import numpy as np >>> from mvpy.utilities import compile >>> @compile.numpy >>> def maths_a(x: np.ndarray, y: np.ndarray) -> np.ndarray: >>> return x @ y.t() >>> @compile.numpy(disable = True) >>> def maths_b(x: np.ndarray, y: np.ndarray) -> np.ndarray: >>> return x @ y.t()