-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Closed
Labels
Description
Describe the issue:
For assignment using __setitem__, numpy is calling the __array__ method on the value with a copy=True. This can be seen by running the code example.
Reproduce the code example:
import numpy
class MyThing(object):
def __array__(self, dtype=None, copy=None):
print(f"MyThing.__array__(dtype={dtype}, copy={copy})")
return numpy.ones((5, 5))
u = numpy.zeros((5, 5))
v = MyThing()
u[...] = vError message:
No response
Python and NumPy Versions:
2.2.1
3.13.1 | packaged by conda-forge | (main, Dec 5 2024, 21:09:18) [Clang 18.1.8 ]
Runtime Environment:
No response
Context for the issue:
This additional copy on a common operation will be extremely inefficient.
Reactions are currently unavailable