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

Function get_array_function

numpy/core/src/multiarray/arrayfunction_override.c:29–50  ·  view source on GitHub ↗

* Get an object's __array_function__ method in the fastest way possible. * Never raises an exception. Returns NULL if the method doesn't exist. */

Source from the content-addressed store, hash-verified

27 * Never raises an exception. Returns NULL if the method doesn't exist.
28 */
29static PyObject *
30get_array_function(PyObject *obj)
31{
32 static PyObject *ndarray_array_function = NULL;
33
34 if (ndarray_array_function == NULL) {
35 ndarray_array_function = get_ndarray_array_function();
36 }
37
38 /* Fast return for ndarray */
39 if (PyArray_CheckExact(obj)) {
40 Py_INCREF(ndarray_array_function);
41 return ndarray_array_function;
42 }
43
44 PyObject *array_function = PyArray_LookupSpecial(obj, npy_ma_str_array_function);
45 if (array_function == NULL && PyErr_Occurred()) {
46 PyErr_Clear(); /* TODO[gh-14801]: propagate crashes during attribute access? */
47 }
48
49 return array_function;
50}
51
52
53/*

Calls 2

PyArray_LookupSpecialFunction · 0.85

Tested by

no test coverage detected