11

Suppose I save a numpy array to a file, "arr.npy", using numpy.save() and that I do this using a particular python version, numpy version, and OS.

Can I load, using numpy.load(), arr.npy on a different OS using a different version of python or numpy? Are there any restrictions, such as backwards compatibility?

waldol1
  • 1,841
  • 2
  • 18
  • 22
  • As an alternative proposal, a good way for serialization of numerical data is the hdf5 format e.g. with pytables. It is a well documented, platform independent with fast in access (e.g. partial matrices), language independent and respects endianness. – Bort Mar 10 '15 at 12:49

1 Answers1

17

Yes. The .npy format is documented here:

https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html#module-numpy.lib.format

Note this comment in the source code (emphasis mine):

The .npy format is the standard binary file format in NumPy for persisting a single arbitrary NumPy array on disk. The format stores all of the shape and dtype information necessary to reconstruct the array correctly even on another machine with a different architecture.

FriendFX
  • 2,929
  • 1
  • 34
  • 63
wim
  • 338,267
  • 99
  • 616
  • 750
  • Great, thanks. It would be nice to get that added to the online docs here: http://docs.scipy.org/doc/numpy/reference/generated/numpy.save.html – waldol1 Mar 10 '15 at 22:39