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

Function npy_new_coercion_cache

numpy/core/src/multiarray/array_coercion.c:615–641  ·  view source on GitHub ↗

* Steals a reference to the object. */

Source from the content-addressed store, hash-verified

613 * Steals a reference to the object.
614 */
615static inline int
616npy_new_coercion_cache(
617 PyObject *converted_obj, PyObject *arr_or_sequence, npy_bool sequence,
618 coercion_cache_obj ***next_ptr, int ndim)
619{
620 coercion_cache_obj *cache;
621 if (_coercion_cache_num > 0) {
622 _coercion_cache_num--;
623 cache = _coercion_cache_cache[_coercion_cache_num];
624 }
625 else {
626 cache = PyMem_Malloc(sizeof(coercion_cache_obj));
627 }
628 if (cache == NULL) {
629 Py_DECREF(arr_or_sequence);
630 PyErr_NoMemory();
631 return -1;
632 }
633 cache->converted_obj = converted_obj;
634 cache->arr_or_sequence = arr_or_sequence;
635 cache->sequence = sequence;
636 cache->depth = ndim;
637 cache->next = NULL;
638 **next_ptr = cache;
639 *next_ptr = &(cache->next);
640 return 0;
641}
642
643/**
644 * Unlink coercion cache item.

Calls

no outgoing calls

Tested by

no test coverage detected