numba

class numba.struct(fields=(), name=None, readonly=False, packed=False, **kwargs)

Create a struct type. Fields may be ordered or unordered. Unordered fields will be ordered from big types to small types (for better alignment).

>>> struct([('a', int_), ('b', float_)], name='Foo') # ordered struct
struct Foo { int a, float b }
>>> struct(a=int_, b=float_, name='Foo') # unordered struct
struct Foo { float b, int a }
>>> struct(a=int32, b=int32, name='Foo') # unordered struct
struct Foo { int32 a, int32 b }
>>> S = struct(a=complex128, b=complex64, c=struct(f1=double, f2=double, f3=int32))
>>> S
struct { struct { double f1, double f2, int32 f3 } c, complex128 a, complex64 b }
>>> S.offsetof('a')
24
numba.autojit(template_signature=None, backend='ast', target='cpu', nopython=False, locals=None, **kwargs)

Creates a function that dispatches to type-specialized LLVM functions based on the input argument types. If no specialized function exists for a set of input argument types, the dispatcher creates and caches a new specialized function at call time.

numba.jit(restype=None, argtypes=None, backend='ast', target='cpu', nopython=False, **kws)

Compile a function given the input and return types.

There are multiple ways to specify the type signature:

  • Using the restype and argtypes arguments, passing Numba types.
  • By constructing a Numba function type and passing that as the first argument to the decorator. You can create a function type by calling an exisiting Numba type, which is the return type, and the arguments to that call define the argument types. For example, f8(f8) would create a Numba function type that takes a single double-precision floating point value argument, and returns a double-precision floating point value.
  • As above, but using a string instead of a constructed function type. Example: jit("f8(f8)").

If backend=’bytecode’ the bytecode translator is used, if backend=’ast’ the AST translator is used. By default, the AST translator is used. Note that the bytecode translator is deprecated as of the 0.3 release.

numba.export(signature, **kws)

Construct a decorator that takes a function and exports one

A signature is a string with

name ret_type(arg_type, argtype, ...)

numba.exportmany(signatures, **kws)

A Decorator that exports many signatures for a single function

numba.typeof(variable)

Get the type of a variable.

Used outside of Numba code, infers the type for the object.

Previous topic

Numba Module Reference

Next topic

numba.ast_constant_folding

This Page