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

Function get_handler_version

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

Source from the content-addressed store, hash-verified

604}
605
606NPY_NO_EXPORT PyObject *
607get_handler_version(PyObject *NPY_UNUSED(self), PyObject *args)
608{
609 PyObject *arr=NULL;
610 if (!PyArg_ParseTuple(args, "|O:get_handler_version", &arr)) {
611 return NULL;
612 }
613 if (arr != NULL && !PyArray_Check(arr)) {
614 PyErr_SetString(PyExc_ValueError, "if supplied, argument must be an ndarray");
615 return NULL;
616 }
617 PyObject *mem_handler;
618 PyDataMem_Handler *handler;
619 PyObject *version;
620 if (arr != NULL) {
621 mem_handler = PyArray_HANDLER((PyArrayObject *) arr);
622 if (mem_handler == NULL) {
623 Py_RETURN_NONE;
624 }
625 Py_INCREF(mem_handler);
626 }
627 else {
628 mem_handler = PyDataMem_GetHandler();
629 if (mem_handler == NULL) {
630 return NULL;
631 }
632 }
633 handler = (PyDataMem_Handler *) PyCapsule_GetPointer(mem_handler, "mem_handler");
634 if (handler == NULL) {
635 Py_DECREF(mem_handler);
636 return NULL;
637 }
638 version = PyLong_FromLong(handler->version);
639 Py_DECREF(mem_handler);
640 return version;
641}

Callers 1

test_set_policyFunction · 0.85

Calls 2

PyArray_HANDLERFunction · 0.85
PyDataMem_GetHandlerFunction · 0.85

Tested by 1

test_set_policyFunction · 0.68