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

Function unpack_tuple

numpy/core/src/multiarray/mapping.c:179–194  ·  view source on GitHub ↗

* Unpack a tuple into an array of new references. Returns the number of objects * unpacked. * * Useful if a tuple is being iterated over multiple times, or for a code path * that doesn't always want the overhead of allocating a tuple. */

Source from the content-addressed store, hash-verified

177 * that doesn't always want the overhead of allocating a tuple.
178 */
179static inline npy_intp
180unpack_tuple(PyTupleObject *index, PyObject **result, npy_intp result_n)
181{
182 npy_intp n, i;
183 n = PyTuple_GET_SIZE(index);
184 if (n > result_n) {
185 PyErr_SetString(PyExc_IndexError,
186 "too many indices for array");
187 return -1;
188 }
189 for (i = 0; i < n; i++) {
190 result[i] = PyTuple_GET_ITEM(index, i);
191 Py_INCREF(result[i]);
192 }
193 return n;
194}
195
196/* Unpack a single scalar index, taking a new reference to match unpack_tuple */
197static inline npy_intp

Callers 1

unpack_indicesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected