[Numpy-discussion] Preserving NumPy views when pickling

Robert Kern robert.kern at gmail.com
Tue Oct 25 20:29:54 EDT 2016


On Tue, Oct 25, 2016 at 5:09 PM, Matthew Harrigan <
harrigan.matthew at gmail.com> wrote:
>
> It seems pickle keeps track of references for basic python types.
>
> x = [1]
> y = [x]
> x,y = pickle.loads(pickle.dumps((x,y)))
> x.append(2)
> print(y)
> >>> [[1,2]]
>
> Numpy arrays are different but references are forgotten after
pickle/unpickle.  Shared objects do not remain shared.  Based on the quote
below it could be considered bug with numpy/pickle.

Not a bug, but an explicit design decision on numpy's part.

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161025/7f7a6649/attachment.html>


More information about the NumPy-Discussion mailing list