Skip to content

ENH: Replace updateifcopy arrays. #9257

Closed
@charris

Description

@charris

Arrays with the NPY_ARRAY_UPDATEIFCOPY set are not compatible with python interpreters that do not use refcounting, PyPy in particular. It most cases it should be possible to replace them with a function call, and in those places where that is not possible, such as flatiter.__array__ we should be able to return array copies instead. Updateifcopy arrays are created in the following spots

numpy/core/src/umath/reduction.c:190:        if (PyArray_SetUpdateIfCopyBase(ret_copy, (PyArrayObject *)ret) < 0) {
numpy/core/src/multiarray/iterators.c:1111:            if (PyArray_SetUpdateIfCopyBase(ret, it->ao) < 0) {
numpy/core/src/multiarray/multiarraymodule.c:810:            if (PyArray_SetUpdateIfCopyBase(out_buf, out) < 0) {
numpy/core/src/multiarray/cblasfuncs.c:429:            if (PyArray_SetUpdateIfCopyBase(out_buf, out) < 0) {
numpy/core/src/multiarray/nditer_constr.c:2926:                if (PyArray_SetUpdateIfCopyBase(temp, op[iop]) < 0) {
numpy/core/src/multiarray/ctors.c:2010:            if (PyArray_SetUpdateIfCopyBase(ret, arr) < 0) {
numpy/core/src/multiarray/mapping.c:3208:        if (PyArray_SetUpdateIfCopyBase(a_copy, a) < 0) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions