summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-12-21 10:14:00 -0800
committerGitHub <noreply@github.com>2017-12-21 10:14:00 -0800
commit10f00f660685316a0d8063331c1e515b0edb309c (patch)
treec4894240a0513e86533d1a15d48e1b1d5fa0349b
parent81b1d4031b121a1ce5ab04b4a88d62facee80aca (diff)
parent7ebb000f41b08b06c8e16c735cd8faae857b0006 (diff)
downloadpython-numpy-10f00f660685316a0d8063331c1e515b0edb309c.tar.gz
python-numpy-10f00f660685316a0d8063331c1e515b0edb309c.tar.bz2
python-numpy-10f00f660685316a0d8063331c1e515b0edb309c.zip
Merge pull request #10250 from mhvk/array-ufunc-remove-some-unnecessary-work
MAINT: Check for __array_ufunc__ before doing anything else.
-rw-r--r--numpy/core/src/umath/ufunc_object.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index daeef45bb..6e8556e29 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -4078,26 +4078,22 @@ ufunc_generic_call(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
PyObject *override = NULL;
int errval;
- /*
- * Initialize all array objects to NULL to make cleanup easier
- * if something goes wrong.
- */
- for (i = 0; i < ufunc->nargs; i++) {
- mps[i] = NULL;
- }
-
errval = PyUFunc_CheckOverride(ufunc, "__call__", args, kwds, &override);
if (errval) {
return NULL;
}
else if (override) {
- for (i = 0; i < ufunc->nargs; i++) {
- PyArray_DiscardWritebackIfCopy(mps[i]);
- Py_XDECREF(mps[i]);
- }
return override;
}
+ /*
+ * Initialize all array objects to NULL to make cleanup easier
+ * if something goes wrong.
+ */
+ for (i = 0; i < ufunc->nargs; i++) {
+ mps[i] = NULL;
+ }
+
errval = PyUFunc_GenericFunction(ufunc, args, kwds, mps);
if (errval < 0) {
for (i = 0; i < ufunc->nargs; i++) {