[Numpy-discussion] Preserving NumPy views when pickling

Nathaniel Smith njs at pobox.com
Tue Oct 25 16:07:52 EDT 2016

On Tue, Oct 25, 2016 at 12:38 PM, Stephan Hoyer <shoyer at gmail.com> wrote:
> With a custom wrapper class, it's possible to preserve NumPy views when
> pickling:
> https://stackoverflow.com/questions/13746601/preserving-numpy-view-when-pickling
> This can result in significant time/space savings with pickling views along
> with base arrays and brings the behavior of NumPy more in line with Python
> proper. Is this something that we can/should port into NumPy itself?

Concretely, what do would you suggest should happen with:

base = np.zeros(100000000)
view = base[:10]

# case 1
pickle.dump(view, file)

# case 2
pickle.dump(base, file)
pickle.dump(view, file)

# case 3
pickle.dump(view, file)
pickle.dump(base, file)


Nathaniel J. Smith -- https://vorpus.org

More information about the NumPy-Discussion mailing list