2.8. Deviations from Python semantics

2.8.1. Integer width

While Python has arbitrary-sized integers, integers in Numba-compiled functions get a fixed size through type inference (usually, the size of a machine integer). This means that arithmetic operations can wrapround or produce undefined results or overflow.

Type inference can be overriden by an explicit type specification, if fine-grained control of integer width is desired.

2.8.2. Boolean inversion

Calling the bitwise complement operator (the ~ operator) on a Python boolean returns an integer, while the same operator on a Numpy boolean returns another boolean:

>>> ~True
>>> ~np.bool_(True)

Numba follows the Numpy semantics.

2.8.3. Global and closure variables

In nopython mode, global and closure variables are frozen by Numba: a Numba-compiled function sees the value of those variables at the time the function was compiled. Also, it is not possible to change their values from the function.

To modify a global variable within a function, you can pass it as an argument and modify it in place without the need to explicitly return it.


This document needs completing.