> -----Original Message----- > From: Christian Gollwitzer <aurio...@gmx.de> > Sent: Thursday, November 26, 2020 3:26 AM > To: python-list@python.org > Subject: Re: Why can't numpy array be restored to saved value? > > Am 25.11.20 um 07:47 schrieb pjfarl...@earthlink.net: > > 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? > > > > I know I am missing something basic here. I thought I understood the > > concepts of immutable vs mutable values but obviously I missed something. > > <Snipped> > > Because this does not copy the array, rather it creates a view into the > original array. This is an optimization to avoid copying. If you want a > copy, do svary = npary.copy()
Thank you for the explanation. I did indeed find that using the copy() function did what I needed to do. Peter -- https://mail.python.org/mailman/listinfo/python-list