File: utils.rst

package info (click to toggle)
numba 0.61.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,316 kB
  • sloc: python: 211,580; ansic: 15,233; cpp: 6,544; javascript: 424; sh: 322; makefile: 173
file content (34 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

=========
Utilities
=========

Dealing with pointers
=====================

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


.. function:: 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 :func:`~ctypes.POINTER`, or a :class:`~ctypes.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).


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

   Same as :func:`~numba.carray`, but the data is assumed to be laid out
   in Fortran order, and the array view is constructed accordingly.