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

pjfarley3 at earthlink.net pjfarley3 at earthlink.net
Thu Nov 26 13:08:37 EST 2020


> -----Original Message-----
> From: Greg Ewing <greg.ewing at canterbury.ac.nz>
> Sent: Thursday, November 26, 2020 12:01 AM
> To: python-list at python.org
> Subject: Re: Why can't numpy array be restored to saved value?
> 
> 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

Thank you for that explanation.  I will certainly watch out for it in the future.

Peter



More information about the Python-list mailing list