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

Function arraydescr_protocol_descr_get

numpy/core/src/multiarray/descriptor.c:2122–2152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2120
2121
2122NPY_NO_EXPORT PyObject *
2123arraydescr_protocol_descr_get(PyArray_Descr *self, void *NPY_UNUSED(ignored))
2124{
2125 PyObject *dobj, *res;
2126 PyObject *_numpy_internal;
2127
2128 if (!PyDataType_HASFIELDS(self)) {
2129 /* get default */
2130 dobj = PyTuple_New(2);
2131 if (dobj == NULL) {
2132 return NULL;
2133 }
2134 PyTuple_SET_ITEM(dobj, 0, PyUnicode_FromString(""));
2135 PyTuple_SET_ITEM(dobj, 1, arraydescr_protocol_typestr_get(self, NULL));
2136 res = PyList_New(1);
2137 if (res == NULL) {
2138 Py_DECREF(dobj);
2139 return NULL;
2140 }
2141 PyList_SET_ITEM(res, 0, dobj);
2142 return res;
2143 }
2144
2145 _numpy_internal = PyImport_ImportModule("numpy.core._internal");
2146 if (_numpy_internal == NULL) {
2147 return NULL;
2148 }
2149 res = PyObject_CallMethod(_numpy_internal, "_array_descr", "O", self);
2150 Py_DECREF(_numpy_internal);
2151 return res;
2152}
2153
2154/*
2155 * returns 1 for a builtin type

Callers 2

array_protocol_descr_getFunction · 0.85
array_struct_getFunction · 0.85

Calls 1

Tested by

no test coverage detected