Why can't numpy array be restored to saved value?

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 26 00:00:47 EST 2020


On 25/11/20 7:47 pm, pjfarley3 at earthlink.net wrote:
> Why isn't the final value of the numpy array npary in the following code the
> same as the initial value before some but not all elements of the array were
> changed to a new value?

Slicing a numpy array doesn't copy anything, it just
gives you another view of the underlying data.

This is a trap you need to watch out for, since it's
different from the way sequences normally behave in
Python.

-- 
Greg



More information about the Python-list mailing list