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

Function _array_descr_builtin

numpy/core/src/multiarray/hashdescr.c:71–100  ·  view source on GitHub ↗

* Add to l all the items which uniquely define a builtin type */

Source from the content-addressed store, hash-verified

69 * Add to l all the items which uniquely define a builtin type
70 */
71static int _array_descr_builtin(PyArray_Descr* descr, PyObject *l)
72{
73 Py_ssize_t i;
74 PyObject *t, *item;
75 char nbyteorder = _normalize_byteorder(descr->byteorder);
76
77 /*
78 * For builtin type, hash relies on : kind + byteorder + flags +
79 * type_num + elsize + alignment
80 */
81 t = Py_BuildValue("(cccii)", descr->kind, nbyteorder,
82 descr->flags, descr->elsize, descr->alignment);
83
84 for(i = 0; i < PyTuple_Size(t); ++i) {
85 item = PyTuple_GetItem(t, i);
86 if (item == NULL) {
87 PyErr_SetString(PyExc_SystemError,
88 "(Hash) Error while computing builtin hash");
89 goto clean_t;
90 }
91 PyList_Append(l, item);
92 }
93
94 Py_DECREF(t);
95 return 0;
96
97clean_t:
98 Py_DECREF(t);
99 return -1;
100}
101
102/*
103 * Walk inside the fields and add every item which will be used for hashing

Callers 1

_array_descr_walkFunction · 0.85

Calls 1

_normalize_byteorderFunction · 0.85

Tested by

no test coverage detected