nodes Package

nodes Package

numba.nodes.call_obj(call_node, py_func=None)
numba.nodes.call_pyfunc(py_func, args)

Generate an object call for a python function given during compilation time

numba.nodes.const(obj, type)
numba.nodes.index(node, constant_index, load=True, type=int)
numba.nodes.inject_print(context, module, node)

Returns whether the given node is a Name

numba.nodes.print_(env, node)
numba.nodes.print_llvm(env, type, llvm_value)
numba.nodes.typednode(node, type)

Set a type and simple typed variable on a node

basenodes Module

class numba.nodes.basenodes.CloneNode(node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Clone a CloneableNode. This allows the node’s sub-expressions to be re-used without re-evaluating them.

The CloneableNode must be evaluated before the CloneNode is evaluated!

class numba.nodes.basenodes.CloneableNode(node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Create a node that can be cloned. This allows sub-expressions to be re-used without re-evaluating them.

class numba.nodes.basenodes.ExprNode(**kwargs)

Bases: numba.nodes.basenodes.Node

Node that is an expression.

class numba.nodes.basenodes.ExpressionNode(stmts, expr, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Node that allows an expression to execute a bunch of statements first.

class numba.nodes.basenodes.FunctionWrapperNode(wrapped_function, signature, orig_py_func, fake_pyfunc, orig_py_func_name)

Bases: numba.nodes.basenodes.Node

This code is a wrapper function callable from Python using NumbaFunction (see numba/numbafunction.c):

PyObject ()(PyObject *self, PyObject *args)

It unpacks the tuple to native types, calls the wrapped function, and coerces the return type back to an object.

class numba.nodes.basenodes.Name(id, ctx, *args, **kwargs)

Bases: _ast.Name, numba.nodes.basenodes.ExprNode

cf_maybe_null = False
raise_unbound_node = None
class numba.nodes.basenodes.Node(**kwargs)

Bases: _ast.AST

Superclass for Numba AST nodes

class numba.nodes.basenodes.WithNoPythonNode(**kwargs)

Bases: numba.nodes.basenodes.WithPythonNode

with nopython: ...

class numba.nodes.basenodes.WithPythonNode(**kwargs)

Bases: numba.nodes.basenodes.Node

with python: ...


bitwise Module


callnodes Module

class numba.nodes.callnodes.ComplexConjugateNode(complex_node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode


class numba.nodes.callnodes.FunctionCallNode(signature, args, name='')

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.callnodes.LLMacroNode(signature, macro, *args, **kw)

Bases: numba.nodes.callnodes.NativeCallNode

Inject a low-level macro in the function at the call site.

Low-level macros are Python functions that take a FunctionCache instance, a LLVM builder instance, and a set of arguments, construct LLVM code, and return some kind of LLVM value result. The passed signature should reflect the Numba types of the expected input parameters, and the type of the resulting value (this does not restrict polymorphism at the LLVM type level in the macro expansion function).

class numba.nodes.callnodes.LLVMExternalFunctionNode(signature, fname)

Bases: numba.nodes.basenodes.ExprNode

For calling an external llvm function where you only have the signature and the function name.

class numba.nodes.callnodes.LLVMIntrinsicNode(signature, args, func_name, **kw)

Bases: numba.nodes.callnodes.NativeCallNode

Call an llvm intrinsic function

class numba.nodes.callnodes.MathCallNode(signature, args, llvm_func, py_func=None, badval=None, goodval=None, exc_type=None, exc_msg=None, exc_args=None, skip_self=False, **kw)

Bases: numba.nodes.callnodes.NativeCallNode

Low level call a libc math function

class numba.nodes.callnodes.NativeCallNode(signature, args, llvm_func, py_func=None, badval=None, goodval=None, exc_type=None, exc_msg=None, exc_args=None, skip_self=False, **kw)

Bases: numba.nodes.callnodes.FunctionCallNode

class numba.nodes.callnodes.NativeFunctionCallNode(signature, function_node, args, **kw)

Bases: numba.nodes.callnodes.NativeCallNode

Call a function which is given as a node

class numba.nodes.callnodes.ObjectCallNode(signature, func, args, keywords=None, py_func=None, **kw)

Bases: numba.nodes.callnodes.FunctionCallNode

class numba.nodes.callnodes.PointerCallNode(signature, args, pointer, py_func=None, **kw)

Bases: numba.nodes.callnodes.NativeCallNode

Call a ctypes function

cfnodes Module

class numba.nodes.cfnodes.FlowNode(**kwargs)

Bases: numba.nodes.basenodes.Node

Node that has control flow basic blocks.

cond_block = None
else_block = None
exit_block = None
if_block = None
class numba.nodes.cfnodes.For(**kwargs)

Bases: _ast.For, numba.nodes.cfnodes.FlowNode

A for loop node. Has the basic block attributes from FlowNode

class numba.nodes.cfnodes.If(**kwargs)

Bases: _ast.If, numba.nodes.cfnodes.FlowNode

An if statement node. Has the basic block attributes from FlowNode

class numba.nodes.cfnodes.LowLevelBasicBlockNode(body, label='unnamed', **kwargs)

Bases: numba.nodes.basenodes.Node

Evaluate a statement or expression in a new LLVM basic block.

create_block(translator, label=None)
class numba.nodes.cfnodes.MaybeUnusedNode(name_node)

Bases: numba.nodes.basenodes.Node

Wraps an ast.Name() to indicate that the result may be unused.

class numba.nodes.cfnodes.While(**kwargs)

Bases: _ast.While, numba.nodes.cfnodes.FlowNode

A while loop node. Has the basic block attributes from FlowNode

continue_block = None
numba.nodes.cfnodes.build_if(cls=<class 'numba.nodes.cfnodes.If'>, **kwargs)
numba.nodes.cfnodes.delete_control_blocks(flow_node, flow)

Remove all control flow basic blocks from the CFG given a FlowNode and the CFG. Also removes Name references from cf_references.

numba.nodes.cfnodes.if_else(op, cond_left, cond_right, lhs, rhs)

Implements ‘lhs if cond_left <op> cond_right else rhs’

numba.nodes.cfnodes.merge_cfg_in_ast(basic_block_fields, bodies, node)

Merge CFG blocks into the AST. E.g.

While(test=x, body=y)


While(test=ControlBlock(0, body=[x]), body=ControlBlock(1, body=[y]))

closurenodes Module

class numba.nodes.closurenodes.ClosureCallNode(closure_type, call_node, **kwargs)

Bases: numba.nodes.callnodes.NativeCallNode

Call to closure or inner function.

class numba.nodes.closurenodes.ClosureNode(env, func_def, closure_type, outer_py_func, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Inner functions or closures.

When coerced to an object, a wrapper PyMethodDef gets created, and at call time a function is dynamically created with the closure scope.

AST FunctionDef of the function
Outer Python function (or None!)
class numba.nodes.closurenodes.ClosureScopeLoadNode(**kwargs)

Bases: numba.nodes.basenodes.ExprNode

Load the closure scope for the function or NULL

type = void *
class numba.nodes.closurenodes.InstantiateClosureScope(func_def, scope_ext_type, scope_type, outer_scope, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

coercionnodes Module

class numba.nodes.coercionnodes.CastNode(node, type)

Bases: numba.nodes.basenodes.ExprNode

Explicit cast by user, e.g. double(value)

class numba.nodes.coercionnodes.CoerceToNative(node, dst_type, name='')

Bases: numba.nodes.coercionnodes.CoercionNode

Coerce objects to native values

class numba.nodes.coercionnodes.CoerceToObject(node, dst_type, name='')

Bases: numba.nodes.coercionnodes.CoercionNode

Coerce native values to objects

class numba.nodes.coercionnodes.CoercionNode(node, dst_type, name='')

Bases: numba.nodes.basenodes.ExprNode

Coerce a node to a different type

classmethod coerce(node_or_nodes, dst_type)

Numpy array attributes, such as ‘data’, get rewritten to direct accesses. Since they are being coerced back to objects, use a generic attribute access instead.


dst_type is always the same as type, and ‘type’ is kept consistent with Variable.type

verify_conversion(dst_type, node)
class numba.nodes.coercionnodes.DeferredCoercionNode(node, variable)

Bases: numba.nodes.basenodes.ExprNode

Coerce to the type of the given variable. The type of the variable may change in the meantime (e.g. may be promoted or demoted).

class numba.nodes.coercionnodes.PromotionNode(**kwargs)

Bases: numba.nodes.basenodes.ExprNode

Coerces a variable of some type to another type for a phi node in a successor block.

class numba.nodes.coercionnodes.UntypedCoercion(node, type)

Bases: numba.nodes.basenodes.ExprNode

Coerce a node to the destination type. The node need not yet have a type or variable.

constnodes Module

class numba.nodes.constnodes.ConstNode(pyval, type=None)

Bases: numba.nodes.basenodes.ExprNode

Wrap a constant.

numba.nodes.constnodes.get_pointer_address(value, type)

excnodes Module

class numba.nodes.excnodes.CheckErrorNode(return_value, badval=None, goodval=None, exc_type=None, exc_msg=None, exc_args=None, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Check for an exception.

badval: if this value is returned, propagate an error goodval: if this value is not returned, propagate an error

If exc_type, exc_msg and optionally exc_args are given, an error is raised instead of propagating it.

See RaiseNode for the exc_* arguments.

class numba.nodes.excnodes.PropagateNode(**kwargs)

Bases: numba.nodes.basenodes.ExprNode

Propagate an exception (jump to the error label). This is resolved at code generation time and can be generated at any moment.

class numba.nodes.excnodes.PyErr_OccurredNode(node)

Bases: numba.nodes.basenodes.ExprNode

Check for a set Python exception using PyErr_Occurred().

Can be set any time after type inference. This node is resolved during late specialization.

class numba.nodes.excnodes.RaiseNode(exc_type, exc_msg, exc_args=None, print_on_trap=True, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Raise an exception.

exception_type: The Python exception type

exc_type: The Python exception as an AST node
May be passed in as a Python exception type
exc_msg: The message to print as an AST node
May be passed in as a string
exc_args: If given, must be an list of AST nodes representing the
arguments to PyErr_Format (matching the format specifiers at runtime in exc_msg)

extnodes Module

class numba.nodes.extnodes.AutojitExtensionMethod(obj, attr, method, **kwargs)

Bases: numba.nodes.extnodes.ExtensionMethod

class numba.nodes.extnodes.ExtTypeAttribute(value, attr, variable, ctx, ext_type, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

classmethod from_known_attribute(value, attr, ctx, ext_type)

Create an extension type attribute node if the attribute is known to exist (and isn’t being inferred)

class numba.nodes.extnodes.ExtensionMethod(obj, attr, method, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

call_node = None
class numba.nodes.extnodes.NewExtObjectNode(ext_type, args, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Instantiate an extension type. Currently unused.

llvmnodes Module

class numba.nodes.llvmnodes.BadValue(type)

Bases: numba.nodes.llvmnodes.LLVMValueRefNode


alias of UserNode

class numba.nodes.llvmnodes.LLVMValueRefNode(type, llvm_value)

Bases: numba.nodes.basenodes.ExprNode

Wrap an LLVM value.

metadata Module

Allow annotating AST nodes with some metadata, and querying for that metadata.

numba.nodes.metadata.annotate(env, node, **flags)
numba.nodes.metadata.query(env, node, key, default=None)

numpynodes Module

class numba.nodes.numpynodes.ArrayAttributeNode(attribute_name, array)

Bases: numba.nodes.basenodes.ExprNode

is_read_only = True
class numba.nodes.numpynodes.ArrayNewEmptyNode(type, shape, is_fortran=False, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Allocate a new array with data.

class numba.nodes.numpynodes.ArrayNewNode(type, data, shape, strides, base=None, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Allocate a new array given the attributes.

class numba.nodes.numpynodes.DataPointerNode(node, slice, ctx)

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.numpynodes.MultiArrayAPINode(name, signature, args)

Bases: numba.nodes.callnodes.NativeCallNode

numba.nodes.numpynodes.PyArray_Empty(args, name='PyArray_Empty')

Low-level specialized equivalent of ArrayNewNode

class numba.nodes.numpynodes.ShapeAttributeNode(array)

Bases: numba.nodes.numpynodes.ArrayAttributeNode

numba.nodes.numpynodes.get_shape(builder, tbaa_metadata, shape_pointer, ndim)

Load the shape values from an ndarray

numba.nodes.numpynodes.get_strides(builder, tbaa_metadata, strides_pointer, ndim)

Load the stride values from an ndarray


objectnodes Module

class numba.nodes.objectnodes.DecrefNode(value, **kwargs)

Bases: numba.nodes.objectnodes.IncrefNode

class numba.nodes.objectnodes.IncrefNode(value, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.objectnodes.NoneNode(**kwargs)

Bases: numba.nodes.basenodes.ExprNode

Return None.

type = none
variable = <Variable(type=none)>
class numba.nodes.objectnodes.ObjectInjectNode(object, type=None, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Refer to a Python object in the llvm code.

class numba.nodes.objectnodes.ObjectTempNode(node, incref=False)

Bases: numba.nodes.basenodes.ExprNode

Coerce a node to a temporary which is reference counted.

class numba.nodes.objectnodes.ObjectTempRefNode(obj_temp_node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Reference an ObjectTempNode, without evaluating its subexpressions. The ObjectTempNode must already have been evaluated.

pointernodes Module

class numba.nodes.pointernodes.DereferenceNode(pointer, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Dereference a pointer

class numba.nodes.pointernodes.PointerFromObject(node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Bitcast objects to void *

type = void *
variable = <Variable(type=void *)>
numba.nodes.pointernodes.pointer_add(pointer, offset)
numba.nodes.pointernodes.ptrfromint(intval, dst_ptr_type)
numba.nodes.pointernodes.value_at_offset(obj_node, offset, dst_type)

Perform (dst_type) (((char *) my_object) + offset)

structnodes Module

Struct and complex nodes.

Structs are allocated on the stack, and not mutated as values. This is because mutations are attribute or index assignments, which are not recognized as variable assignments. Hence mutation cannot propagate new values. So we mutate what we have on the stack.

class numba.nodes.structnodes.ComplexAttributeNode(value, attr)

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.structnodes.ComplexNode(real, imag)

Bases: numba.nodes.basenodes.ExprNode

type = complex128
variable = <Variable(type=complex128)>
class numba.nodes.structnodes.StructAttribute(value, attr, ctx, type, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.structnodes.StructVariable(node, **kwargs)

Bases: numba.nodes.basenodes.ExprNode

Tells the type inferencer that the node is actually a valid struct that we can mutate. For instance

func().a = 2

is wrong if func() returns a struct by value. So we only allow references like struct.a = 2 and array[i].a = 2.


tempnodes Module

class numba.nodes.tempnodes.TempLoadNode(temp, invariant=False)

Bases: numba.nodes.basenodes.ExprNode

class numba.nodes.tempnodes.TempNode(type, name=None, dst_variable=None)

Bases: numba.nodes.basenodes.ExprNode

Create a temporary to store values in. Does not perform reference counting.


TBAA metadata node unique to this temporary. This is valid since one cannot take the address of a temporary.

temp_counter = 0
class numba.nodes.tempnodes.TempStoreNode(temp, invariant=False)

Bases: numba.nodes.tempnodes.TempLoadNode

usernode Module

class numba.nodes.usernode.UserNode(**kwargs)

Bases: numba.nodes.basenodes.ExprNode

Node that users can subclass and insert in the AST without using mixins to provide user-specified functionality.

actual_name = 'UserNode'

Generate code for this node.

Must return an LLVM Value.


Infer the type of this node and set it self.type.

The return value will replace this node in the AST.


Just before code generation. Useful to rewrite this node in terms of other existing fundamental operations.

Implementing this method is optional.

class numba.nodes.usernode.UserNodeMeta(what, bases=None, dict=None)

Bases: type


alias of UserNode


alias of UserNode