On Thu, Dec 26, 2024 at 5:48 PM Benjamin Root via NumPy-Discussion < numpy-discussion@python.org> wrote:
> Seems to make sense to me? Or is the following a bug? > > >>> import numpy as np > >>> u = np.zeros(5) > >>> v = np.ones(5) > >>> u > array([0., 0., 0., 0., 0.]) > >>> u[...] = v > >>> u > array([1., 1., 1., 1., 1.]) > >>> v[4] = 5 > >>> v > array([1., 1., 1., 1., 5.]) > >>> u > array([1., 1., 1., 1., 1.]) > > If you don't do a copy, then it is a view, right? And so, should modifying > v[4] change u[4]? Relatedly, if these were object arrays, of mutable > objects, should mutating u[4] point to the exact same instance as v[4] and > mutating it in one array means that the other array "sees" the same changes? > No one is suggesting that behavior should change. The issue is whether or not an unnecessary, _additional_ copy gets made when converting a not-exactly-an-`ndarray` object to an `ndarray` object before doing the assignment (which always copies values over to the destination array). -- Robert Kern
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com