summaryrefslogtreecommitdiff
path: root/doc/source/reference/c-api
diff options
context:
space:
mode:
authorKai Striega <kaistriega@gmail.com>2020-01-22 08:49:41 +0800
committerSebastian Berg <sebastian@sipsolutions.net>2020-01-21 16:49:41 -0800
commite94cec800304a6a467cf90ce4e7d3e207770b4b4 (patch)
tree29f4c70b9b5dee5a95d1d03da59d73c510c85ae3 /doc/source/reference/c-api
parent1d05717115990a1bd5dd547b70cd960354063702 (diff)
downloadnumpy-e94cec800304a6a467cf90ce4e7d3e207770b4b4.tar.gz
MAINT: Const qualify UFunc inner loops (gh-15355)
This PR const qualifies the dimension and strides arguments of PyUFuncGenericFunction. Const qualified arguments make it simpler to reason about the behaviour of these ufuncs and prevents accidental mutation. As the const is now required this PR also const qualifies calls to PyUFuncGenericFunction inside the NumPy source code. This closes #15252
Diffstat (limited to 'doc/source/reference/c-api')
-rw-r--r--doc/source/reference/c-api/ufunc.rst62
1 files changed, 32 insertions, 30 deletions
diff --git a/doc/source/reference/c-api/ufunc.rst b/doc/source/reference/c-api/ufunc.rst
index c9cc60141..ec23adf2d 100644
--- a/doc/source/reference/c-api/ufunc.rst
+++ b/doc/source/reference/c-api/ufunc.rst
@@ -77,7 +77,7 @@ Functions
signature:
.. c:function:: void loopfunc(
- char** args, npy_intp* dimensions, npy_intp* steps, void* data)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* data)
*args*
@@ -108,8 +108,10 @@ Functions
.. code-block:: c
static void
- double_add(char **args, npy_intp *dimensions, npy_intp *steps,
- void *extra)
+ double_add(char **args,
+ npy_intp const *dimensions,
+ npy_intp const *steps,
+ void *extra)
{
npy_intp i;
npy_intp is1 = steps[0], is2 = steps[1];
@@ -311,37 +313,37 @@ functions stored in the functions member of the PyUFuncObject
structure.
.. c:function:: void PyUFunc_f_f_As_d_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_d_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_f_f( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_g_g( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_F_F_As_D_D( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_F_F( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_D_D( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_G_G( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_e_e( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_e_e_As_f_f( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_e_e_As_d_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
Type specific, core 1-d functions for ufuncs where each
calculation is obtained by calling a function taking one input
@@ -357,37 +359,37 @@ structure.
C-function that takes double and returns double.
.. c:function:: void PyUFunc_ff_f_As_dd_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_ff_f( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_dd_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_gg_g( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_FF_F_As_DD_D( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_DD_D( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_FF_F( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_GG_G( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_ee_e( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_ee_e_As_ff_f( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_ee_e_As_dd_d( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
Type specific, core 1-d functions for ufuncs where each
calculation is obtained by calling a function taking two input
@@ -400,10 +402,10 @@ structure.
to use the underlying function that takes a different data type.
.. c:function:: void PyUFunc_O_O( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
.. c:function:: void PyUFunc_OO_O( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
One-input, one-output, and two-input, one-output core 1-d functions
for the :c:data:`NPY_OBJECT` data type. These functions handle reference
@@ -413,7 +415,7 @@ structure.
PyObject *)`` for :c:func:`PyUFunc_OO_O`.
.. c:function:: void PyUFunc_O_O_method( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
This general purpose 1-d core function assumes that *func* is a string
representing a method of the input object. For each
@@ -421,7 +423,7 @@ structure.
and its *func* method is called returning the result to the output array.
.. c:function:: void PyUFunc_OO_O_method( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
This general purpose 1-d core function assumes that *func* is a
string representing a method of the input object that takes one
@@ -431,7 +433,7 @@ structure.
of *args*.
.. c:function:: void PyUFunc_On_Om( \
- char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+ char** args, npy_intp const *dimensions, npy_intp const *steps, void* func)
This is the 1-d core function used by the dynamic ufuncs created
by umath.frompyfunc(function, nin, nout). In this case *func* is a