MCPcopy Create free account
hub / github.com/numpy/numpy / PyArray_LookupSpecial

Function PyArray_LookupSpecial

numpy/core/src/common/get_attr_string.h:49–65  ·  view source on GitHub ↗

* Lookup a special method, following the python approach of looking up * 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. It does check base ndarray and numpy scalar types. * * In future, could be made more like _Py_LookupSpecial */

Source from the content-addressed store, hash-verified

47 * In future, could be made more like _Py_LookupSpecial
48 */
49static inline PyObject *
50PyArray_LookupSpecial(PyObject *obj, PyObject *name_unicode)
51{
52 PyTypeObject *tp = Py_TYPE(obj);
53
54 /* We do not need to check for special attributes on trivial types */
55 if (_is_basic_python_type(tp)) {
56 return NULL;
57 }
58 PyObject *res = PyObject_GetAttr((PyObject *)tp, name_unicode);
59
60 if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
61 PyErr_Clear();
62 }
63
64 return res;
65}
66
67
68/*

Callers 3

get_array_functionFunction · 0.85
binop_should_deferFunction · 0.85

Calls 1

_is_basic_python_typeFunction · 0.85

Tested by

no test coverage detected