You are viewing archived documentation from the old Numba documentation site. The current documentation is located at https://numba.readthedocs.io.


Dealing with pointers

These functions can be called from pure Python as well as in nopython mode.

numba.carray(ptr, shape, dtype=None)

Return a Numpy array view over the data pointed to by ptr with the given shape, in C order. If dtype is given, it is used as the array’s dtype, otherwise the array’s dtype is inferred from ptr’s type. As the returned array is a view, not a copy, writing to it will modify the original data.

ptr should be a ctypes pointer object (either a typed pointer as created using POINTER(), or a c_void_p).

shape should be an integer or a tuple of integers.

dtype should be a Numpy dtype or scalar class (i.e. both np.dtype('int8') and np.int8 are accepted).

numba.farray(ptr, shape, dtype=None)

Same as carray(), but the data is assumed to be laid out in Fortran order, and the array view is constructed accordingly.