numba package
Submodules
numba.assume module
A place to store all assumptions made in various part of the code base.
This allow us to do a usage analysis to discover all code that is assuming
something.
Each assumption is defined as a global variable. Its value is the
description of the assumption. Code that makes the assumption should
assert the_assumption
numba.bytecode module
From NumbaPro
-
class numba.bytecode.ByteCode(func)
Bases: numba.bytecode.ByteCodeBase
-
class numba.bytecode.ByteCodeBase(func, func_name, argspec, filename, co_names, co_varnames, co_consts, co_freevars, table, labels)
Bases: object
-
argspec
-
co_consts
-
co_freevars
-
co_names
-
co_varnames
-
dump()
-
filename
-
func
-
func_name
-
labels
-
table
-
class numba.bytecode.ByteCodeInst(offset, opcode, arg)
Bases: object
- offset:
byte offset of opcode
- opcode:
opcode integer value
- arg:
instruction arg
- lineno:
-1 means unknown
-
arg
-
classmethod get(offset, opname, arg)
-
get_jump_target()
-
is_jump
-
is_terminator
-
lineno
-
next
-
offset
-
opcode
-
opname
-
class numba.bytecode.ByteCodeIter(code)
Bases: object
-
next()
-
read_arg(size)
-
class numba.bytecode.ByteCodeOperation(inst, args)
Bases: object
-
exception numba.bytecode.ByteCodeSupportError
Bases: exceptions.Exception
-
class numba.bytecode.CustomByteCode(func, func_name, argspec, filename, co_names, co_varnames, co_consts, co_freevars, table, labels)
Bases: numba.bytecode.ByteCodeBase
-
numba.bytecode.get_code_object(obj)
Shamelessly borrowed from llpython
-
numba.bytecode.get_function_object(obj)
Objects that wraps function should provide a “__numba__” magic attribute
that contains a name of an attribute that contains the actual python
function object.
-
class numba.bytecode.opcode_info
Bases: tuple
opcode_info(argsize,)
-
argsize
Alias for field number 0
numba.callwrapper module
-
class numba.callwrapper.PyCallWrapper(context, module, func, fndesc, exceptions)
Bases: object
-
build()
-
build_wrapper(api, builder, args, kws)
-
make_const_string(string)
-
make_exception_switch(api, builder, code)
Handle user defined exceptions.
Build a switch to check which exception class was raised.
-
make_keywords(kws)
numba.cffi_support module
Support for CFFI. Allows checking whether objects are CFFI functions and
obtaining the pointer and numba signature.
-
class numba.cffi_support.ExternCFunction(symbol, cstring)
Bases: numba.types.Function
-
numba.cffi_support.get_pointer(cffi_func)
Get a pointer to the underlying function for a CFFI function as an
integer.
-
numba.cffi_support.is_cffi_func(obj)
Check whether the obj is a CFFI function
-
numba.cffi_support.make_function_type(cffi_func)
-
numba.cffi_support.map_type(cffi_type)
Map CFFI type to numba type
numba.cgutils module
-
class numba.cgutils.IfBranchObj(builder, bbenter, bbend)
Bases: object
-
class numba.cgutils.MetadataKeyStore(module, name)
Bases: object
-
get()
Get string value
-
set(value)
Add a string value
-
class numba.cgutils.Structure(context, builder, value=None, ref=None)
Bases: object
-
class numba.cgutils.VerboseProxy(obj)
Bases: object
Use to wrap llvm.core.Builder to track where segfault happens
-
numba.cgutils.alloca_once(builder, ty, name='')
-
numba.cgutils.append_basic_block(builder, name='')
-
numba.cgutils.as_bool_byte(builder, value)
-
numba.cgutils.for_range(*args, **kwds)
-
numba.cgutils.gep(builder, ptr, *inds)
-
numba.cgutils.get_function(builder)
-
numba.cgutils.get_item_pointer(builder, aryty, ary, inds, wraparound=False)
-
numba.cgutils.get_item_pointer2(builder, data, shape, strides, layout, inds, wraparound=False)
-
numba.cgutils.get_module(builder)
-
numba.cgutils.get_null_value(ltype)
-
numba.cgutils.get_range_from_slice(builder, slicestruct)
-
numba.cgutils.get_record_data(builder, record)
-
numba.cgutils.get_record_member(builder, record, offset, typ)
-
numba.cgutils.get_strides_from_slice(builder, ndim, strides, slice, ax)
-
numba.cgutils.goto_block(*args, **kwds)
-
numba.cgutils.goto_entry_block(*args, **kwds)
-
numba.cgutils.guard_null(context, builder, value)
-
numba.cgutils.guard_zero(context, builder, value)
-
numba.cgutils.if_likely(*args, **kwds)
-
numba.cgutils.if_unlikely(*args, **kwds)
-
numba.cgutils.ifelse(*args, **kwds)
-
numba.cgutils.ifnot(*args, **kwds)
-
numba.cgutils.ifthen(*args, **kwds)
-
numba.cgutils.inbound_gep(builder, ptr, *inds)
-
numba.cgutils.init_record_by_ptr(builder, ltyp, ptr)
-
numba.cgutils.is_false(builder, val)
-
numba.cgutils.is_neg_int(builder, val)
-
numba.cgutils.is_not_null(builder, val)
-
numba.cgutils.is_null(builder, val)
-
numba.cgutils.is_pointer(ltyp)
-
numba.cgutils.is_scalar_zero(builder, value)
-
numba.cgutils.is_struct(ltyp)
-
numba.cgutils.is_struct_ptr(ltyp)
-
numba.cgutils.is_true(builder, val)
-
numba.cgutils.loop_nest(*args, **kwds)
-
numba.cgutils.normalize_slice(builder, slice, length)
Clip stop
-
numba.cgutils.pack_array(builder, values)
-
numba.cgutils.printf(builder, format_string, *values)
-
numba.cgutils.set_branch_weight(builder, brinst, trueweight, falseweight)
-
numba.cgutils.set_record_data(builder, record, buf)
-
numba.cgutils.terminate(builder, bbend)
-
numba.cgutils.unpack_tuple(builder, tup, count)
numba.compiler module
-
class numba.compiler.CompileResult
Bases: tuple
CompileResult(typing_context, target_context, entry_point, entry_point_addr, typing_error, type_annotation, llvm_module, llvm_func, signature, objectmode, lifted, fndesc)
-
entry_point
Alias for field number 2
-
entry_point_addr
Alias for field number 3
-
fndesc
Alias for field number 11
-
lifted
Alias for field number 10
-
llvm_func
Alias for field number 7
-
llvm_module
Alias for field number 6
-
objectmode
Alias for field number 9
-
signature
Alias for field number 8
-
target_context
Alias for field number 1
-
type_annotation
Alias for field number 5
-
typing_context
Alias for field number 0
-
typing_error
Alias for field number 4
-
class numba.compiler.Flags
Bases: numba.utils.ConfigOptions
-
OPTIONS = frozenset(['no_wraparound', 'enable_looplift', 'no_compile', 'boundcheck', 'force_pyobject', 'enable_pyobject'])
-
numba.compiler.compile_bytecode(typingctx, targetctx, bc, args, return_type, flags, locals, lifted=())
- return_type
Use None to indicate
-
numba.compiler.compile_isolated(func, args, return_type=None, flags=Flags(), locals={})
Compile the function is an isolated environment.
Good for testing.
-
numba.compiler.compile_result(**kws)
-
numba.compiler.ir_optimize_for_py_stage(interp)
This passes breaks semantic for the type inferer but they reduces
refct calls for object mode.
-
numba.compiler.legalize_given_types(args, return_type)
-
numba.compiler.legalize_return_type(return_type, interp, targetctx)
Only accept array return type iff it is passed into the function.
-
numba.compiler.native_lowering_stage(targetctx, interp, typemap, restype, calltypes, nocompile)
-
numba.compiler.py_lowering_stage(targetctx, interp, nocompile)
-
numba.compiler.translate_stage(bytecode)
-
numba.compiler.type_inference_stage(typingctx, interp, args, return_type, locals={})
numba.config module
numba.controlflow module
-
class numba.controlflow.CFBlock(offset)
Bases: object
-
class numba.controlflow.ControlFlowAnalysis(bytecode)
Bases: object
bytecode
blocks
blockseq
- doms: dict of set
Dominators
- backbone: set of block offsets
The set of block that is common to all possible code path.
-
dead_block_elimin()
-
iterblocks()
Return all blocks in sequence of occurrence
-
iterliveblocks()
Return all live blocks in sequence of occurrence
-
jump(target)
-
op_BREAK_LOOP(inst)
-
op_FOR_ITER(inst)
-
op_JUMP_ABSOLUTE(inst)
-
op_JUMP_FORWARD(inst)
-
op_JUMP_IF_FALSE(inst)
-
op_JUMP_IF_FALSE_OR_POP(inst)
-
op_JUMP_IF_TRUE(inst)
-
op_JUMP_IF_TRUE_OR_POP(inst)
-
op_POP_BLOCK(inst)
-
op_POP_JUMP_IF_FALSE(inst)
-
op_POP_JUMP_IF_TRUE(inst)
-
op_RAISE_VARARGS(inst)
-
op_RETURN_VALUE(inst)
-
op_SETUP_LOOP(inst)
-
run()
-
numba.controlflow.find_dominators(blocks)
numba.ctypes_support module
This file fixes portability issues for ctypes
numba.ctypes_utils module
This file fixes portability issues for ctypes
-
numba.ctypes_utils.convert_ctypes(ctypeobj)
-
numba.ctypes_utils.is_ctypes_funcptr(obj)
-
numba.ctypes_utils.make_function_type(cfnptr)
numba.dataflow module
-
class numba.dataflow.BlockInfo(offset)
Bases: object
-
append(inst, **kws)
-
dump()
-
make_temp()
-
pop()
-
push(val)
-
terminator
-
tos
-
class numba.dataflow.DataFlowAnalysis(cfa)
Bases: object
Perform stack2reg
This is necessary to resolve blocks that propagates stack value.
This would allow the use of and and or and python2.6 jumps.
-
dispatch(info, inst)
-
dump()
-
dup_topx(info, count)
-
op_BINARY_ADD(info, inst)
-
op_BINARY_AND(info, inst)
-
op_BINARY_DIVIDE(info, inst)
-
op_BINARY_FLOOR_DIVIDE(info, inst)
-
op_BINARY_LSHIFT(info, inst)
-
op_BINARY_MODULO(info, inst)
-
op_BINARY_MULTIPLY(info, inst)
-
op_BINARY_OR(info, inst)
-
op_BINARY_POWER(info, inst)
-
op_BINARY_RSHIFT(info, inst)
-
op_BINARY_SUBSCR(info, inst)
-
op_BINARY_SUBTRACT(info, inst)
-
op_BINARY_TRUE_DIVIDE(info, inst)
-
op_BINARY_XOR(info, inst)
-
op_BREAK_LOOP(info, inst)
-
op_BUILD_LIST(info, inst)
-
op_BUILD_SLICE(info, inst)
slice(TOS1, TOS) or slice(TOS2, TOS1, TOS)
-
op_BUILD_TUPLE(info, inst)
-
op_CALL_FUNCTION(info, inst)
-
op_COMPARE_OP(info, inst)
-
op_DUP_TOP(info, inst)
-
op_DUP_TOPX(info, inst)
-
op_DUP_TOP_TWO(info, inst)
-
op_FOR_ITER(info, inst)
-
op_GET_ITER(info, inst)
-
op_INPLACE_ADD(info, inst)
-
op_INPLACE_AND(info, inst)
-
op_INPLACE_DIVIDE(info, inst)
-
op_INPLACE_FLOOR_DIVIDE(info, inst)
-
op_INPLACE_LSHIFT(info, inst)
-
op_INPLACE_MODULO(info, inst)
-
op_INPLACE_MULTIPLY(info, inst)
-
op_INPLACE_OR(info, inst)
-
op_INPLACE_POWER(info, inst)
-
op_INPLACE_RSHIFT(info, inst)
-
op_INPLACE_SUBTRACT(info, inst)
-
op_INPLACE_TRUE_DIVIDE(info, inst)
-
op_INPLACE_XOR(info, inst)
-
op_JUMP_ABSOLUTE(info, inst)
-
op_JUMP_FORWARD(info, inst)
-
op_JUMP_IF_FALSE(info, inst)
-
op_JUMP_IF_FALSE_OR_POP(info, inst)
-
op_JUMP_IF_TRUE(info, inst)
-
op_JUMP_IF_TRUE_OR_POP(info, inst)
-
op_LOAD_ATTR(info, inst)
-
op_LOAD_CONST(info, inst)
-
op_LOAD_DEREF(info, inst)
-
op_LOAD_FAST(info, inst)
-
op_LOAD_GLOBAL(info, inst)
-
op_POP_BLOCK(info, inst)
-
op_POP_JUMP_IF_FALSE(info, inst)
-
op_POP_JUMP_IF_TRUE(info, inst)
-
op_POP_TOP(info, inst)
-
op_PRINT_ITEM(info, inst)
-
op_PRINT_NEWLINE(info, inst)
-
op_RAISE_VARARGS(info, inst)
-
op_RETURN_VALUE(info, inst)
-
op_ROT_FOUR(info, inst)
-
op_ROT_THREE(info, inst)
-
op_ROT_TWO(info, inst)
-
op_SETUP_LOOP(info, inst)
-
op_SLICE_0(info, inst)
TOS = TOS[:]
-
op_SLICE_1(info, inst)
TOS = TOS1[TOS:]
-
op_SLICE_2(info, inst)
TOS = TOS1[:TOS]
-
op_SLICE_3(info, inst)
TOS = TOS2[TOS1:TOS]
-
op_STORE_ATTR(info, inst)
-
op_STORE_FAST(info, inst)
-
op_STORE_SLICE_0(info, inst)
TOS[:] = TOS1
-
op_STORE_SLICE_1(info, inst)
TOS1[TOS:] = TOS2
-
op_STORE_SLICE_2(info, inst)
TOS1[:TOS] = TOS2
-
op_STORE_SLICE_3(info, inst)
TOS2[TOS1:TOS] = TOS3
-
op_STORE_SUBSCR(info, inst)
-
op_UNARY_INVERT(info, inst)
-
op_UNARY_NEGATIVE(info, inst)
-
op_UNARY_NOT(info, inst)
-
op_UNARY_POSITIVE(info, inst)
-
op_UNPACK_SEQUENCE(info, inst)
-
run()
-
run_on_block(blk)
-
class numba.dataflow.LoopBlock
Bases: object
-
iterator
numba.decorators module
Contains function decorators and target_registry
-
numba.decorators.autojit(*args, **kws)
Deprecated.
Use jit instead. Calls to jit internally.
-
numba.decorators.jit(signature_or_function=None, argtypes=None, restype=None, locals={}, target='cpu', **targetoptions)
- jit([signature_or_function, [locals={}, [target=’cpu’,
- [**targetoptions]]]])
The function can be used as the following versions:
jit(signature, [target=’cpu’, [**targetoptions]]) -> jit(function)
Equivalent to:
d = dispatcher(function, targetoptions)
d.compile(signature)
Create a dispatcher object for a python function and default
target-options. Then, compile the funciton with the given signature.
Example:
@jit(“void(int32, float32)”)
def foo(x, y):
jit(function) -> dispatcher
Same as old autojit. Create a dispatcher function object that
specialize at call site.
Example:
jit([target=’cpu’, [**targetoptions]]) -> configured_jit(function)
Same as old autojit and 2). But configure with target and default
target-options.
Example:
@jit(target=’cpu’, nopython=True)
def foo(x, y):
The CPU (default target) defines the following:
nopython: [bool]
Set to True to disable the use of PyObjects and Python API
calls. The default behavior is to allow the use of PyObjects and
Python API. Default value is False.
forceobj: [bool]
Set to True to force the use of PyObjects for every value. Default
value is False.
-
numba.decorators.njit(*args, **kws)
Equavilent to jit(nopython=True)
numba.dispatcher module
-
class numba.dispatcher.LiftedLoop(bytecode, typingctx, targetctx, locals, flags)
Bases: numba.dispatcher.Overloaded
-
compile(sig)
-
class numba.dispatcher.Overloaded(py_func, locals={}, targetoptions={})
Bases: _dispatcher.Dispatcher
Abstract class. Subclass should define targetdescr class attribute.
-
add_overload(cres)
-
compile(sig, locals={}, **targetoptions)
-
disable_compile(val=True)
Disable the compilation of new signatures at call time.
-
get_overload(sig)
-
inspect_types()
-
is_compiling
-
jit(sig, **kws)
Alias of compile(sig, **kws)
-
signatures
Returns a list of compiled function signatures.
-
classmethod typeof_pyval(val)
This is called from numba._dispatcher as a fallback if the native code
cannot decide the type.
numba.dummyarray module
-
class numba.dummyarray.Array(dims, itemsize)
Bases: object
A dummy numpy array-like object. Consider it an array without the
actual data, but offset from the base data pointer.
- dims: tuple of Dim
- describing each dimension of the array
- ndim: int
- number of dimension
- shape: tuple of int
- size of each dimension
- strides: tuple of int
- stride of each dimension
- itemsize: int
- itemsize
- extent: (start, end)
- start and end offset containing the memory region
-
classmethod from_desc(offset, shape, strides, itemsize)
-
is_c_contig
-
is_f_contig
-
iter_contiguous_extent()
Generates extents
-
ravel(order='C')
-
reshape(*newshape, **kws)
-
class numba.dummyarray.Dim(start, stop, size, stride)
Bases: object
A single dimension of the array
- start:
- start offset
- stop:
- stop offset
- size:
- number of items
- stride:
- item stride
-
copy(start=None, stop=None, size=None, stride=None)
-
get_offset(idx)
-
is_contiguous(itemsize)
-
normalize(base)
-
size
-
start
-
stop
-
stride
-
class numba.dummyarray.Extent
Bases: tuple
Extent(begin, end)
-
begin
Alias for field number 0
-
end
Alias for field number 1
-
numba.dummyarray.compute_index(indices, dims)
-
numba.dummyarray.is_element_indexing(item, ndim)
-
numba.dummyarray.iter_strides_c_contig(arr, shape=None)
yields the c-contigous strides
-
numba.dummyarray.iter_strides_f_contig(arr, shape=None)
yields the f-contigous strides
numba.errcode module
-
class numba.errcode.Enum(init=0)
Bases: object
-
get()
numba.findlib module
-
numba.findlib.find_file(pat, libdir=None)
-
numba.findlib.find_lib(libname, libdir=None, platform=None)
-
numba.findlib.get_lib_dir()
Anaconda specific
numba.interpreter module
-
class numba.interpreter.Interpreter(bytecode)
Bases: object
A bytecode interpreter that builds up the IR.
-
block_constains_opname(offset, opname)
-
code_consts
-
code_freevars
-
code_locals
-
code_names
-
current_scope
-
dump(file=None)
-
get(name)
-
get_closure_value(index)
Get a value from the cell contained in this function’s closure.
-
get_global_value(name)
Get a global value from the func_global (first) or
as a builtins (second). If both failed, return a ir.UNDEFINED.
-
init_first_block()
-
insert_block(offset, scope=None, loc=None)
-
interpret()
-
op_BINARY_ADD(inst, lhs, rhs, res)
-
op_BINARY_AND(inst, lhs, rhs, res)
-
op_BINARY_DIVIDE(inst, lhs, rhs, res)
-
op_BINARY_FLOOR_DIVIDE(inst, lhs, rhs, res)
-
op_BINARY_LSHIFT(inst, lhs, rhs, res)
-
op_BINARY_MODULO(inst, lhs, rhs, res)
-
op_BINARY_MULTIPLY(inst, lhs, rhs, res)
-
op_BINARY_OR(inst, lhs, rhs, res)
-
op_BINARY_POWER(inst, lhs, rhs, res)
-
op_BINARY_RSHIFT(inst, lhs, rhs, res)
-
op_BINARY_SUBSCR(inst, target, index, res)
-
op_BINARY_SUBTRACT(inst, lhs, rhs, res)
-
op_BINARY_TRUE_DIVIDE(inst, lhs, rhs, res)
-
op_BINARY_XOR(inst, lhs, rhs, res)
-
op_BREAK_LOOP(inst)
-
op_BUILD_LIST(inst, items, res)
-
op_BUILD_SLICE(inst, start, stop, step, res, slicevar)
-
op_BUILD_TUPLE(inst, items, res)
-
op_CALL_FUNCTION(inst, func, args, kws, res)
-
op_COMPARE_OP(inst, lhs, rhs, res)
-
op_FOR_ITER(inst, iterator, indval, pred)
Assign new block other this instruction.
-
op_GET_ITER(inst, value, res)
-
op_INPLACE_ADD(inst, lhs, rhs, res)
-
op_INPLACE_AND(inst, lhs, rhs, res)
-
op_INPLACE_DIVIDE(inst, lhs, rhs, res)
-
op_INPLACE_FLOOR_DIVIDE(inst, lhs, rhs, res)
-
op_INPLACE_LSHIFT(inst, lhs, rhs, res)
-
op_INPLACE_MODULO(inst, lhs, rhs, res)
-
op_INPLACE_MULTIPLY(inst, lhs, rhs, res)
-
op_INPLACE_OR(inst, lhs, rhs, res)
-
op_INPLACE_POWER(inst, lhs, rhs, res)
-
op_INPLACE_RSHIFT(inst, lhs, rhs, res)
-
op_INPLACE_SUBTRACT(inst, lhs, rhs, res)
-
op_INPLACE_TRUE_DIVIDE(inst, lhs, rhs, res)
-
op_INPLACE_XOR(inst, lhs, rhs, res)
-
op_JUMP_ABSOLUTE(inst)
-
op_JUMP_FORWARD(inst)
-
op_JUMP_IF_FALSE(inst, pred)
-
op_JUMP_IF_FALSE_OR_POP(inst, pred)
-
op_JUMP_IF_TRUE(inst, pred)
-
op_JUMP_IF_TRUE_OR_POP(inst, pred)
-
op_LOAD_ATTR(inst, item, res)
-
op_LOAD_CONST(inst, res)
-
op_LOAD_DEREF(inst, res)
-
op_LOAD_GLOBAL(inst, res)
-
op_POP_BLOCK(inst, delitem=None)
-
op_POP_JUMP_IF_FALSE(inst, pred)
-
op_POP_JUMP_IF_TRUE(inst, pred)
-
op_PRINT_ITEM(inst, item, printvar, res)
-
op_PRINT_NEWLINE(inst, printvar, res)
-
op_RAISE_VARARGS(inst, exc)
-
op_RETURN_VALUE(inst, retval)
-
op_SETUP_LOOP(inst)
-
op_SLICE_0(inst, base, res, slicevar, indexvar, nonevar)
-
op_SLICE_1(inst, base, start, nonevar, res, slicevar, indexvar)
-
op_SLICE_2(inst, base, nonevar, stop, res, slicevar, indexvar)
-
op_SLICE_3(inst, base, start, stop, res, slicevar, indexvar)
-
op_STORE_ATTR(inst, target, value)
-
op_STORE_FAST(inst, value)
-
op_STORE_SLICE_0(inst, base, value, slicevar, indexvar, nonevar)
-
op_STORE_SLICE_1(inst, base, start, nonevar, value, slicevar, indexvar)
-
op_STORE_SLICE_2(inst, base, nonevar, stop, value, slicevar, indexvar)
-
op_STORE_SLICE_3(inst, base, start, stop, value, slicevar, indexvar)
-
op_STORE_SUBSCR(inst, target, index, value)
-
op_UNARY_INVERT(inst, value, res)
-
op_UNARY_NEGATIVE(inst, value, res)
-
op_UNARY_NOT(inst, value, res)
-
op_UNARY_POSITIVE(inst, value, res)
-
op_UNPACK_SEQUENCE(inst, sequence, stores, iterobj)
-
store(value, name)
-
verify()
numba.io_support module
numba.ir module
-
class numba.ir.Assign(value, target, loc)
Bases: numba.ir.Stmt
-
class numba.ir.Block(scope, loc)
Bases: object
A code block
-
append(inst)
-
dump(file=<open file '<stdout>', mode 'w' at 0x10028d150>)
-
insert_before_terminator(stmt)
-
is_terminated
-
remove(inst)
-
terminator
-
verify()
-
class numba.ir.Branch(cond, truebr, falsebr, loc)
Bases: numba.ir.Stmt
-
is_terminator = True
-
class numba.ir.Const(value, loc)
Bases: object
-
class numba.ir.Del(value, loc)
Bases: numba.ir.Stmt
-
class numba.ir.Expr(op, loc, **kws)
Bases: object
-
classmethod binop(fn, lhs, rhs, loc)
-
classmethod build_list(items, loc)
-
classmethod build_tuple(items, loc)
-
classmethod call(func, args, kws, loc)
-
classmethod getattr(value, attr, loc)
-
classmethod getitem(target, index, loc)
-
classmethod getiter(value, loc)
-
classmethod iternext(value, loc)
-
classmethod iternextsafe(value, loc)
-
classmethod itervalid(value, loc)
-
list_vars()
-
classmethod unary(fn, value, loc)
-
class numba.ir.Global(name, value, loc)
Bases: object
-
class numba.ir.Intrinsic(name, type, args)
Bases: object
For inserting intrinsic node into the IR
-
class numba.ir.Jump(target, loc)
Bases: numba.ir.Stmt
-
is_terminator = True
-
class numba.ir.Loc(filename, line, col=None)
Bases: object
Source location
-
strformat()
-
class numba.ir.Loop(entry, exit, condition=None)
Bases: object
-
body
-
condition
-
entry
-
exit
-
valid()
-
verify()
-
exception numba.ir.NotDefinedError
Bases: exceptions.NameError
-
class numba.ir.Raise(exception, loc)
Bases: numba.ir.Stmt
-
is_terminator = True
-
exception numba.ir.RedefinedError
Bases: exceptions.NameError
-
class numba.ir.Return(value, loc)
Bases: numba.ir.Stmt
-
is_terminator = True
-
class numba.ir.Scope(parent, loc)
Bases: object
- parent: Scope
Parent scope
- localvars: VarMap
Scope-local variable map
- loc: Loc
Start of scope location
-
define(name, loc)
Define a variable
-
get(name)
Refer to a variable
-
get_or_define(name, loc)
-
has_parent
-
make_temp(loc)
-
redefine(name, loc)
Redefine if the name is already defined
-
class numba.ir.SetAttr(target, attr, value, loc)
Bases: numba.ir.Stmt
-
class numba.ir.SetItem(target, index, value, loc)
Bases: numba.ir.Stmt
-
class numba.ir.Stmt
Bases: object
-
is_terminator = False
-
class numba.ir.Var(scope, name, loc)
Bases: object
scope: Scope
name: str
- loc: Loc
Definition location
-
is_temp
-
class numba.ir.VarMap
Bases: object
-
define(name, var)
-
get(name)
-
exception numba.ir.VerificationError
Bases: exceptions.Exception
numba.irpasses module
Contains optimization passes for the IR.
-
class numba.irpasses.RemoveRedundantAssign(interp)
Bases: object
Turn assignment pairs into one assignment
-
mark_asssignment(tempassign, offset, inst)
-
run()
-
run_block(blk)
numba.looplifting module
-
numba.looplifting.bind(loops, typingctx, targetctx, locals, flags)
Install loop dispatchers into the module
-
numba.looplifting.bind_loop(loopbc, typingctx, targetctx, locals, flags)
-
numba.looplifting.discover_args_and_returns(bytecode, insts, outer_rds, outer_wrs)
Basic analysis for args and returns
This completely ignores the ordering or the read-writes.
-
numba.looplifting.find_previous_inst(insts, offset)
-
numba.looplifting.find_varnames_uses(bytecode, insts)
-
numba.looplifting.insert_instruction(insts, item)
-
numba.looplifting.insert_loop_call(bytecode, loop, args, lbclist, outer, outerlabels, outernames)
-
numba.looplifting.lift_loop(bytecode)
Lift the top-level loops.
- outer: ByteCode of a copy of the loop-less function.
- loops: a list of ByteCode of the loops.
-
numba.looplifting.make_loop_bytecode(bytecode, loop, args)
-
numba.looplifting.separate_loops(bytecode, outer, loops)
Separate top-level loops from the function
Stores loopless instructions from the original function into outer.
Stores list of loop instructions into loops.
Both outer and loops are list-like (append(item) defined).
-
numba.looplifting.stitch_instructions(outer, loop)
numba.lowering module
-
class numba.lowering.BaseLower(context, fndesc)
Bases: object
Lower IR to LLVM
-
init()
-
init_argument(arg)
-
lower()
-
lower_block(block)
-
post_lower()
Called after all blocks are lowered
-
typeof(varname)
-
class numba.lowering.ExternalFunctionDescriptor(name, restype, argtypes)
Bases: numba.lowering.FunctionDescriptor
A FunctionDescriptor subclass for opaque external functions
(e.g. raw C functions).
-
class numba.lowering.FunctionDescriptor(native, modname, qualname, unique_name, doc, blocks, typemap, restype, calltypes, args, kws, mangler=None, argtypes=None, globals=None)
Bases: object
-
args
-
argtypes
-
blocks
-
calltypes
-
doc
-
globals
-
kws
-
lookup_module()
Return the module in which this function is supposed to exist.
This may be a dummy module if the function was dynamically
generated.
-
mangled_name
-
modname
-
native
-
qualname
-
restype
-
typemap
-
unique_name
-
class numba.lowering.Lower(context, fndesc)
Bases: numba.lowering.BaseLower
-
alloca(name, type)
-
getvar(name)
-
loadvar(name)
-
lower_assign(ty, inst)
-
lower_expr(resty, expr)
-
lower_inst(inst)
-
storevar(value, name)
-
exception numba.lowering.LoweringError(msg, loc)
Bases: exceptions.Exception
-
class numba.lowering.PyIterState(context, builder, value=None, ref=None)
Bases: numba.cgutils.Structure
-
class numba.lowering.PyLower(context, fndesc)
Bases: numba.lowering.BaseLower
-
alloca(name, ltype=None)
Allocate a stack slot and initialize it to NULL.
The default is to allocate a pyobject pointer.
Use ltype to override.
-
builtin_lookup(mod, name)
- mod:
- The __builtins__ dictionary or module
- name: str
- The object to lookup
-
check_error(obj)
-
check_occurred()
-
cleanup()
-
decref(value)
This is allow to be called on non pyobject pointer, in which case
no code is inserted.
If the value is a PyIterState, it unpack the structure and decref
the iterator.
-
get_builtin_obj(name)
-
getvar(name, ltype=None)
-
incref(value)
-
init()
-
init_argument(arg)
-
is_null(obj)
-
loadvar(name)
-
lower_assign(inst)
The returned object must have a new reference
-
lower_const(const)
-
lower_expr(expr)
-
lower_global(name, value)
Check global scope dictionary.
- Check __builtins__.
2a) is it a dictionary (for non __main__ module)
2b) is it a module (for __main__ module)
-
lower_inst(inst)
-
pack_iter(obj)
-
post_lower()
-
return_error_occurred()
-
return_exception_raised()
-
set_iter_valid(state, item)
-
storevar(value, name)
Stores a llvm value and allocate stack slot if necessary.
The llvm value can be of arbitrary type.
-
unpack_iter(state)
-
class numba.lowering.PythonFunctionDescriptor(native, modname, qualname, unique_name, doc, blocks, typemap, restype, calltypes, args, kws, mangler=None, argtypes=None, globals=None)
Bases: numba.lowering.FunctionDescriptor
-
classmethod from_object_mode_function(interp)
Build a FunctionDescriptor for a Python function to be compiled
and executed in object mode.
-
classmethod from_specialized_function(interp, typemap, restype, calltypes, mangler)
Build a FunctionDescriptor for a specialized Python function.
-
numba.lowering.default_mangler(name, argtypes)
numba.macro module
Macro handling passes
Macros are expanded on block-by-block
-
class numba.macro.Macro(name, func, callable=False, argnames=None)
Bases: object
A macro object is expanded to a function call
-
argnames
-
callable
-
func
-
name
-
numba.macro.expand_macros(blocks)
-
numba.macro.expand_macros_in_block(constants, block)
-
numba.macro.module_getattr_folding(constants, block)
numba.numpy_support module
-
numba.numpy_support.from_dtype(dtype)
-
numba.numpy_support.from_struct_dtype(dtype)
-
numba.numpy_support.is_array(val)
-
numba.numpy_support.is_arrayscalar(val)
-
numba.numpy_support.map_arrayscalar_type(val)
-
numba.numpy_support.map_layout(val)
-
numba.numpy_support.numba_types_to_numpy_letter_types(numba_type_seq)
-
numba.numpy_support.numpy_letter_types_to_numba_types(numpy_letter_types_seq)
-
numba.numpy_support.ufunc_find_matching_loop(ufunc, op_dtypes)
numba.pythonapi module
-
exception numba.pythonapi.NativeError
Bases: exceptions.RuntimeError
-
class numba.pythonapi.PythonAPI(context, builder)
Bases: object
-
alloca_obj()
-
bool_from_long(ival)
-
borrow_none()
-
bytes_from_string_and_size(string, size)
-
call(callee, args, kws)
-
call_function_objargs(callee, objargs)
-
complex_adaptor(cobj, cmplx)
-
complex_from_doubles(realval, imagval)
-
complex_imag_as_double(cobj)
-
complex_real_as_double(cobj)
-
decref(obj)
-
dict_getitem_string(dic, name)
Returns a borrowed reference
-
dict_new()
-
dict_pack(keyvalues)
keyvalues: iterable of (str, llvm.Value of PyObject*)
-
dict_setitem_string(dictobj, name, valobj)
-
err_clear()
-
err_occurred()
-
err_set_object(exctype, excval)
-
err_set_string(exctype, msg)
-
float_as_double(fobj)
-
float_from_double(fval)
-
from_native_array(typ, ary)
-
from_native_return(val, typ)
-
from_native_value(val, typ)
-
from_unituple(typ, val)
-
get_module_dict()
-
get_module_dict_symbol()
-
get_null_object()
-
import_module_noblock(modname)
-
incref(obj)
-
iter_next(iterobj)
-
list_new(szval)
-
list_pack(items)
-
list_setitem(seq, idx, val)
Warning: Steals reference to val
-
long_as_longlong(numobj)
-
long_as_ulonglong(numobj)
-
long_from_long(ival)
-
long_from_longlong(numobj)
-
long_from_ssize_t(ival)
-
long_from_ulonglong(numobj)
-
make_none()
-
name_error_type
-
native_error_type
-
numba_array_adaptor(ary, ptr)
-
number_add(lhs, rhs)
-
number_and(lhs, rhs)
-
number_as_ssize_t(numobj)
-
number_divide(lhs, rhs)
-
number_float(val)
-
number_floordivide(lhs, rhs)
-
number_invert(obj)
-
number_long(numobj)
-
number_lshift(lhs, rhs)
-
number_multiply(lhs, rhs)
-
number_negative(obj)
-
number_or(lhs, rhs)
-
number_positive(obj)
-
number_power(lhs, rhs)
-
number_remainder(lhs, rhs)
-
number_rshift(lhs, rhs)
-
number_subtract(lhs, rhs)
-
number_truedivide(lhs, rhs)
-
number_xor(lhs, rhs)
-
object_getattr_string(obj, attr)
-
object_getitem(obj, key)
-
object_getiter(obj)
-
object_istrue(obj)
-
object_not(obj)
-
object_richcompare(lhs, rhs, opstr)
Refer to Python source Include/object.h for macros definition
of the opid.
-
object_setitem(obj, key, val)
-
object_str(obj)
-
parse_tuple(args, fmt, *objs)
-
parse_tuple_and_keywords(args, kws, fmt, keywords, *objs)
-
print_object(obj)
-
print_string(text)
-
raise_exception(exctype, excval)
-
raise_missing_global_error(name)
-
raise_native_error(msg)
-
recreate_record(pdata, size, dtypeaddr)
-
release_record_buffer(pbuf)
-
return_none()
-
sequence_getslice(obj, start, stop)
-
string_as_string(strobj)
-
string_from_constant_string(string)
-
string_from_string_and_size(string, size)
-
sys_write_stdout(fmt, *args)
-
to_native_arg(obj, typ)
-
to_native_array(typ, ary)
-
to_native_value(obj, typ)
-
tuple_getitem(tup, idx)
Borrow reference
-
tuple_new(count)
-
tuple_pack(items)
-
tuple_setitem(tuple_val, index, item)
-
numba.pythonapi.fix_python_api()
Execute once to install special symbols into the LLVM symbol table
numba.sigutils module
-
numba.sigutils.is_signature(sig)
-
numba.sigutils.normalize_signature(sig)
-
numba.sigutils.parse_signature(signature_str)
numba.special module
-
numba.special.typeof(val)
Get the type of a variable or value.
Used outside of Numba code, infers the type for the object.
numba.testing module
-
numba.testing.discover_tests(startdir)
-
numba.testing.multitest()
Run tests in multiple processes.
-
numba.testing.run_tests(suite, descriptions=True, verbosity=2, buffer=True, failfast=False)
-
numba.testing.test()
numba.type_annotations module
-
class numba.type_annotations.SourceLines(func)
Bases: _abcoll.Mapping
-
avail
-
class numba.type_annotations.TypeAnnotation(interp, typemap, calltypes, lifted)
Bases: object
-
annotate()
numba.typeinfer module
Type inference base on CPA.
The algorithm guarantees monotonic growth of type-sets for each variable.
- Steps:
- seed initial types
- build constrains
- propagate constrains
- unify types
Constrain propagation is precise and does not regret (no backtracing).
Constrains push types forward following the dataflow.
-
class numba.typeinfer.BuildTupleConstrain(target, items, loc)
Bases: object
-
class numba.typeinfer.CallConstrain(target, func, args, kws, loc)
Bases: object
Constrain for calling functions.
Perform case analysis foreach combinations of argument types.
-
resolve(context, typevars, fnty)
-
class numba.typeinfer.ConstrainNetwork
Bases: object
- TODO: It is possible to optimize constrain propagation to consider only
- dirty type variables.
-
append(constrain)
-
propagate(context, typevars)
-
class numba.typeinfer.GetAttrConstrain(target, attr, value, loc, inst)
Bases: object
-
class numba.typeinfer.IntrinsicCallConstrain(target, func, args, kws, loc)
Bases: numba.typeinfer.CallConstrain
-
class numba.typeinfer.Propagate(dst, src, loc)
Bases: object
A simple constrain for direct propagation of types for assignments.
-
class numba.typeinfer.SetAttrConstrain(target, attr, value, loc)
Bases: object
-
class numba.typeinfer.SetItemConstrain(target, index, value, loc)
Bases: object
-
class numba.typeinfer.TypeInferer(context, blocks)
Bases: object
Operates on block that shares the same ir.Scope.
-
build_constrain()
-
constrain_statement(inst)
-
dump()
-
get_function_types(typemap)
-
get_return_type(typemap)
-
get_state_token()
The algorithm is monotonic. It can only grow the typesets.
The sum of all lengths of type sets is a cheap and accurate
description of our progress.
-
propagate()
-
seed_return(typ)
Seeding of return value is optional.
-
seed_type(name, typ)
All arguments should be seeded.
-
typeof_assign(inst)
-
typeof_call(inst, target, call)
-
typeof_const(inst, target, const)
-
typeof_expr(inst, target, expr)
-
typeof_global(inst, target, gvar)
-
typeof_intrinsic_call(inst, target, func, *args)
-
typeof_setattr(inst)
-
typeof_setitem(inst)
-
unify()
-
class numba.typeinfer.TypeVar(context, var)
Bases: object
-
add_types(*types)
-
get()
-
getone()
-
lock(typ)
-
union(other)
-
class numba.typeinfer.TypeVarMap
Bases: dict
-
set_context(context)
-
exception numba.typeinfer.TypingError(msg, loc=None)
Bases: exceptions.Exception
numba.types module
These type objects do not have a fixed machine representation. It is up to
the targets to choose their representation.
numba.unittest_support module
This file fixes portability issues for unittest
numba.utils module
-
class numba.utils.BenchmarkResult(func, records, loop)
Bases: object
-
class numba.utils.ConfigOptions
Bases: object
-
OPTIONS = ()
-
copy()
-
set(name)
-
unset(name)
-
class numba.utils.SortedMap(seq)
Bases: _abcoll.Mapping
Immutable
-
class numba.utils.SortedSet(seq)
Bases: _abcoll.Set
-
class numba.utils.UniqueDict
Bases: dict
-
numba.utils.benchmark(func, maxsec=1)
-
numba.utils.bit_length(intval)
-
numba.utils.dict_iteritems(d)
-
numba.utils.dict_itervalues(d)
-
numba.utils.dict_keys(d)
-
numba.utils.dict_values(d)
-
numba.utils.format_time(tm)
-
numba.utils.func_globals(f)
-
numba.utils.iter_next(it)
-
numba.utils.longint(v)
-
numba.utils.runonce(fn)
Module contents
Expose top-level symbols that are safe for import *
-
numba.jit(signature_or_function=None, argtypes=None, restype=None, locals={}, target='cpu', **targetoptions)
- jit([signature_or_function, [locals={}, [target=’cpu’,
- [**targetoptions]]]])
The function can be used as the following versions:
jit(signature, [target=’cpu’, [**targetoptions]]) -> jit(function)
Equivalent to:
d = dispatcher(function, targetoptions)
d.compile(signature)
Create a dispatcher object for a python function and default
target-options. Then, compile the funciton with the given signature.
Example:
@jit(“void(int32, float32)”)
def foo(x, y):
jit(function) -> dispatcher
Same as old autojit. Create a dispatcher function object that
specialize at call site.
Example:
jit([target=’cpu’, [**targetoptions]]) -> configured_jit(function)
Same as old autojit and 2). But configure with target and default
target-options.
Example:
@jit(target=’cpu’, nopython=True)
def foo(x, y):
The CPU (default target) defines the following:
nopython: [bool]
Set to True to disable the use of PyObjects and Python API
calls. The default behavior is to allow the use of PyObjects and
Python API. Default value is False.
forceobj: [bool]
Set to True to force the use of PyObjects for every value. Default
value is False.
-
numba.autojit(*args, **kws)
Deprecated.
Use jit instead. Calls to jit internally.
-
numba.njit(*args, **kws)
Equavilent to jit(nopython=True)
-
numba.vectorize(ftylist[, target='cpu'[, **kws]])
A decorator to create numpy ufunc object from Numba compiled code.
- ftylist: iterable
- An iterable of type signatures, which are either
function type object or a string describing the
function type.
- target: str
- A string for code generation target. Default to “cpu”.
A NumPy universal function
- @vectorize([‘float32(float32, float32)’,
- ‘float64(float64, float64)’])
- def sum(a, b):
- return a + b
-
numba.guvectorize(ftylist, signature[, target='cpu'[, **kws]])
A decorator to create numpy generialized-ufunc object from Numba compiled
code.
- ftylist: iterable
- An iterable of type signatures, which are either
function type object or a string describing the
function type.
- signature: str
- A NumPy generialized-ufunc signature.
e.g. “(m, n), (n, p)->(m, p)”
- target: str
- A string for code generation target. Defaults to “cpu”.
A NumPy generialized universal-function
- @guvectorize([‘void(int32[:,:], int32[:,:], int32[:,:])’,
- ‘void(float32[:,:], float32[:,:], float32[:,:])’],
‘(x, y),(x, y)->(x, y)’)
- def add_2d_array(a, b):
- for i in range(c.shape[0]):
- for j in range(c.shape[1]):
- c[i, j] = a[i, j] + b[i, j]
-
numba.export(prototype)
-
numba.exportmany(prototypes)
-
numba.typeof(val)
Get the type of a variable or value.
Used outside of Numba code, infers the type for the object.