diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-01-24 09:58:46 -0800 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-01-31 20:49:25 -0800 |
commit | 9ea0b47d8b0cfdec685bdeb02ab30aa282221df7 (patch) | |
tree | e50e8556901bf876608bcee001d1598d62634fdc /numpy | |
parent | cab3faf7d6701c17741471426438ae6ce7d7dc18 (diff) | |
download | numpy-9ea0b47d8b0cfdec685bdeb02ab30aa282221df7.tar.gz |
DEP: Deprecate PyUFunc_GenericFunction public C-API function
This function provides mainly the same API as PyObject_Call()
with the exception of skipping ufunc overrides and output array
wraps.
It is fairly unwieldy to use, since ownership of all inputs and
outputs is transferred, but otherwise it still uses args and kwargs
as inputs.
As such, no known usage exists and PyObject_Call seems a reasonable
replacement for possible usage. Keeping it around means that we would
may have to add tests or risk breaking this function when ufunc
code is refactored.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index e4ce437fb..3e0fcc08d 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -3052,17 +3052,15 @@ fail: return retval; } -/*UFUNC_API - * +/* * This generic function is called with the ufunc object, the arguments to it, * and an array of (pointers to) PyArrayObjects which are NULL. * * 'op' is an array of at least NPY_MAXARGS PyArrayObject *. */ -NPY_NO_EXPORT int -PyUFunc_GenericFunction(PyUFuncObject *ufunc, - PyObject *args, PyObject *kwds, - PyArrayObject **op) +static int +PyUFunc_GenericFunction_int(PyUFuncObject *ufunc, + PyObject *args, PyObject *kwds, PyArrayObject **op) { int nin, nout; int i, nop; @@ -3268,6 +3266,27 @@ fail: return retval; } + +/*UFUNC_API*/ +NPY_NO_EXPORT int +PyUFunc_GenericFunction(PyUFuncObject *ufunc, + PyObject *args, PyObject *kwds, PyArrayObject **op) +{ + /* NumPy 1.19, 2020-01-24 */ + if (DEPRECATE( + "PyUFunc_GenericFunction() C-API function is deprecated " + "and expected to be removed rapidly. If you are using it (i.e. see " + "this warning/error), please notify the NumPy developers. " + "As of now it is expected that any use case is served better by " + "the direct use of `PyObject_Call(ufunc, args, kwargs)`. " + "PyUFunc_GenericFunction function has slightly different " + "untested behaviour.") < 0) { + return -1; + } + return PyUFunc_GenericFunction_int(ufunc, args, kwds, op); +} + + /* * Given the output type, finds the specified binary op. The * ufunc must have nin==2 and nout==1. The function may modify @@ -4683,7 +4702,7 @@ ufunc_generic_call(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds) return override; } - errval = PyUFunc_GenericFunction(ufunc, args, kwds, mps); + errval = PyUFunc_GenericFunction_int(ufunc, args, kwds, mps); if (errval < 0) { return NULL; } |