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

Function NPY_TITLE_KEY_check

numpy/core/include/numpy/ndarrayobject.h:217–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215*/
216
217static inline int
218NPY_TITLE_KEY_check(PyObject *key, PyObject *value)
219{
220 PyObject *title;
221 if (PyTuple_Size(value) != 3) {
222 return 0;
223 }
224 title = PyTuple_GetItem(value, 2);
225 if (key == title) {
226 return 1;
227 }
228#ifdef PYPY_VERSION
229 /*
230 * On PyPy, dictionary keys do not always preserve object identity.
231 * Fall back to comparison by value.
232 */
233 if (PyUnicode_Check(title) && PyUnicode_Check(key)) {
234 return PyUnicode_Compare(title, key) == 0 ? 1 : 0;
235 }
236#endif
237 return 0;
238}
239
240/* Macro, for backward compat with "if NPY_TITLE_KEY(key, value) { ..." */
241#define NPY_TITLE_KEY(key, value) (NPY_TITLE_KEY_check((key), (value)))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected