exa.util.nbvars module

Numba Extensions

The numba package provides a mechanism for compiling Python code. With appropriate options, compilation can provide massive speedups to standard Python code. This module provides reasonable compilation options as well as a utility for compiling symbolic (or string) functions to ‘numbafied’ functions.

See also

sympy, symengine, and the compilation engine numba

exa.util.nbvars.numbafy(fn, args, compiler='jit', **nbkws)[source]

Compile a string, sympy expression or symengine expression using numba.

Not all functions are supported by Python’s numerical package (numpy). For difficult cases, valid Python code (as string) may be more suitable than symbolic expressions coming from sympy, symengine, etc. When compiling vectorized functions, include valid signatures (see numba documentation).

Parameters
  • fn – Symbolic expression as sympy/symengine expression or string

  • args (iterable) – Symbolic arguments

  • compiler – String name or callable numba compiler

  • nbkws – Compiler keyword arguments (if none provided, smart defaults are used)

Returns

func – Compiled function

Warning

For vectorized functions, valid signatures are (almost always) required.