summaryrefslogtreecommitdiff
path: root/doc/source/reference/c-api.array.rst
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2019-06-01 01:12:30 -0700
committerEric Wieser <wieser.eric@gmail.com>2019-06-01 10:52:25 -0700
commit458b5bd38aa50d4c903ff1117ea811a29f774709 (patch)
tree724be8e350f41c6072241815338dcff4ea1dbd52 /doc/source/reference/c-api.array.rst
parent392866d1c8dce0abb8cb327a42f8e134f5d2a05e (diff)
downloadnumpy-458b5bd38aa50d4c903ff1117ea811a29f774709.tar.gz
ENH: Pass input strides and dimensions by pointer to const
This makes it possible to call these functions with constant data. It also bakes the contract that the data passed via these pointers will not be changed into the function signatures. This is backwards compatible, because T* can always be passed to a function expecting T const*.
Diffstat (limited to 'doc/source/reference/c-api.array.rst')
-rw-r--r--doc/source/reference/c-api.array.rst33
1 files changed, 17 insertions, 16 deletions
diff --git a/doc/source/reference/c-api.array.rst b/doc/source/reference/c-api.array.rst
index d01d28f0e..e4178ccd7 100644
--- a/doc/source/reference/c-api.array.rst
+++ b/doc/source/reference/c-api.array.rst
@@ -199,8 +199,8 @@ From scratch
^^^^^^^^^^^^
.. c:function:: PyObject* PyArray_NewFromDescr( \
- PyTypeObject* subtype, PyArray_Descr* descr, int nd, npy_intp* dims, \
- npy_intp* strides, void* data, int flags, PyObject* obj)
+ PyTypeObject* subtype, PyArray_Descr* descr, int nd, npy_intp const* dims, \
+ npy_intp const* strides, void* data, int flags, PyObject* obj)
This function steals a reference to *descr*. The easiest way to get one
is using :c:func:`PyArray_DescrFromType`.
@@ -266,8 +266,9 @@ From scratch
base-class array.
.. c:function:: PyObject* PyArray_New( \
- PyTypeObject* subtype, int nd, npy_intp* dims, int type_num, \
- npy_intp* strides, void* data, int itemsize, int flags, PyObject* obj)
+ PyTypeObject* subtype, int nd, npy_intp const* dims, int type_num, \
+ npy_intp const* strides, void* data, int itemsize, int flags, \
+ PyObject* obj)
This is similar to :c:func:`PyArray_NewFromDescr` (...) except you
specify the data-type descriptor with *type_num* and *itemsize*,
@@ -288,7 +289,7 @@ From scratch
are passed in they must be consistent with the dimensions, the
itemsize, and the data of the array.
-.. c:function:: PyObject* PyArray_SimpleNew(int nd, npy_intp* dims, int typenum)
+.. c:function:: PyObject* PyArray_SimpleNew(int nd, npy_intp const* dims, int typenum)
Create a new uninitialized array of type, *typenum*, whose size in
each of *nd* dimensions is given by the integer array, *dims*.The memory
@@ -301,7 +302,7 @@ From scratch
used to create a flexible-type array (no itemsize given).
.. c:function:: PyObject* PyArray_SimpleNewFromData( \
- int nd, npy_intp* dims, int typenum, void* data)
+ int nd, npy_intp const* dims, int typenum, void* data)
Create an array wrapper around *data* pointed to by the given
pointer. The array flags will have a default that the data area is
@@ -316,7 +317,7 @@ From scratch
as the ndarray is deallocated, set the OWNDATA flag on the returned ndarray.
.. c:function:: PyObject* PyArray_SimpleNewFromDescr( \
- int nd, npy_intp* dims, PyArray_Descr* descr)
+ int nd, npy_int const* dims, PyArray_Descr* descr)
This function steals a reference to *descr*.
@@ -330,7 +331,7 @@ From scratch
This macro calls memset, so obj must be contiguous.
.. c:function:: PyObject* PyArray_Zeros( \
- int nd, npy_intp* dims, PyArray_Descr* dtype, int fortran)
+ int nd, npy_intp const* dims, PyArray_Descr* dtype, int fortran)
Construct a new *nd* -dimensional array with shape given by *dims*
and data type given by *dtype*. If *fortran* is non-zero, then a
@@ -339,13 +340,13 @@ From scratch
corresponds to :c:type:`NPY_OBJECT` ).
.. c:function:: PyObject* PyArray_ZEROS( \
- int nd, npy_intp* dims, int type_num, int fortran)
+ int nd, npy_intp const* dims, int type_num, int fortran)
Macro form of :c:func:`PyArray_Zeros` which takes a type-number instead
of a data-type object.
.. c:function:: PyObject* PyArray_Empty( \
- int nd, npy_intp* dims, PyArray_Descr* dtype, int fortran)
+ int nd, npy_intp const* dims, PyArray_Descr* dtype, int fortran)
Construct a new *nd* -dimensional array with shape given by *dims*
and data type given by *dtype*. If *fortran* is non-zero, then a
@@ -355,7 +356,7 @@ From scratch
filled with :c:data:`Py_None`.
.. c:function:: PyObject* PyArray_EMPTY( \
- int nd, npy_intp* dims, int typenum, int fortran)
+ int nd, npy_intp const* dims, int typenum, int fortran)
Macro form of :c:func:`PyArray_Empty` which takes a type-number,
*typenum*, instead of a data-type object.
@@ -2357,8 +2358,8 @@ Other functions
^^^^^^^^^^^^^^^
.. c:function:: Bool PyArray_CheckStrides( \
- int elsize, int nd, npy_intp numbytes, npy_intp* dims, \
- npy_intp* newstrides)
+ int elsize, int nd, npy_intp numbytes, npy_intp const* dims, \
+ npy_intp const* newstrides)
Determine if *newstrides* is a strides array consistent with the
memory of an *nd* -dimensional array with shape ``dims`` and
@@ -2370,14 +2371,14 @@ Other functions
*elsize* refer to a single-segment array. Return :c:data:`NPY_TRUE` if
*newstrides* is acceptable, otherwise return :c:data:`NPY_FALSE`.
-.. c:function:: npy_intp PyArray_MultiplyList(npy_intp* seq, int n)
+.. c:function:: npy_intp PyArray_MultiplyList(npy_intp const* seq, int n)
-.. c:function:: int PyArray_MultiplyIntList(int* seq, int n)
+.. c:function:: int PyArray_MultiplyIntList(int const* seq, int n)
Both of these routines multiply an *n* -length array, *seq*, of
integers and return the result. No overflow checking is performed.
-.. c:function:: int PyArray_CompareLists(npy_intp* l1, npy_intp* l2, int n)
+.. c:function:: int PyArray_CompareLists(npy_intp const* l1, npy_intp const* l2, int n)
Given two *n* -length arrays of integers, *l1*, and *l2*, return
1 if the lists are identical; otherwise, return 0.