summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/common/get_attr_string.h2
-rw-r--r--numpy/core/src/common/ufunc_override.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/common/get_attr_string.h b/numpy/core/src/common/get_attr_string.h
index a3e5d5ec8..90eca5ee6 100644
--- a/numpy/core/src/common/get_attr_string.h
+++ b/numpy/core/src/common/get_attr_string.h
@@ -42,7 +42,7 @@ _is_basic_python_type(PyTypeObject *tp)
* on the type object, rather than on the instance itself.
*
* Assumes that the special method is a numpy-specific one, so does not look
- * at builtin types, nor does it look at a base ndarray.
+ * at builtin types. It does check base ndarray and numpy scalar types.
*
* In future, could be made more like _Py_LookupSpecial
*/
diff --git a/numpy/core/src/common/ufunc_override.c b/numpy/core/src/common/ufunc_override.c
index 2c3dc5cb3..4fb4d4b3e 100644
--- a/numpy/core/src/common/ufunc_override.c
+++ b/numpy/core/src/common/ufunc_override.c
@@ -5,6 +5,7 @@
#include "get_attr_string.h"
#include "npy_import.h"
#include "ufunc_override.h"
+#include "scalartypes.h"
/*
* Check whether an object has __array_ufunc__ defined on its class and it
@@ -30,6 +31,11 @@ PyUFuncOverride_GetNonDefaultArrayUfunc(PyObject *obj)
if (PyArray_CheckExact(obj)) {
return NULL;
}
+ /* Fast return for numpy scalar types */
+ if (is_anyscalar_exact(obj)) {
+ return NULL;
+ }
+
/*
* Does the class define __array_ufunc__? (Note that LookupSpecial has fast
* return for basic python types, so no need to worry about those here)