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

Function _deepcopy_call

numpy/core/src/multiarray/methods.c:1627–1674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1625}
1626
1627static int
1628_deepcopy_call(char *iptr, char *optr, PyArray_Descr *dtype,
1629 PyObject *deepcopy, PyObject *visit)
1630{
1631 if (!PyDataType_REFCHK(dtype)) {
1632 return 0;
1633 }
1634 else if (PyDataType_HASFIELDS(dtype)) {
1635 PyObject *key, *value, *title = NULL;
1636 PyArray_Descr *new;
1637 int offset, res;
1638 Py_ssize_t pos = 0;
1639 while (PyDict_Next(dtype->fields, &pos, &key, &value)) {
1640 if (NPY_TITLE_KEY(key, value)) {
1641 continue;
1642 }
1643 if (!PyArg_ParseTuple(value, "Oi|O", &new, &offset,
1644 &title)) {
1645 return -1;
1646 }
1647 res = _deepcopy_call(iptr + offset, optr + offset, new,
1648 deepcopy, visit);
1649 if (res < 0) {
1650 return -1;
1651 }
1652 }
1653 }
1654 else {
1655 PyObject *itemp, *otemp;
1656 PyObject *res;
1657 memcpy(&itemp, iptr, sizeof(itemp));
1658 memcpy(&otemp, optr, sizeof(otemp));
1659 if (itemp == NULL) {
1660 itemp = Py_None;
1661 }
1662 Py_INCREF(itemp);
1663 /* call deepcopy on this argument */
1664 res = PyObject_CallFunctionObjArgs(deepcopy, itemp, visit, NULL);
1665 Py_DECREF(itemp);
1666 if (res == NULL) {
1667 return -1;
1668 }
1669 Py_XDECREF(otemp);
1670 memcpy(optr, &res, sizeof(res));
1671 }
1672 return 0;
1673
1674}
1675
1676
1677static PyObject *

Callers 1

array_deepcopyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected