[Numpy-discussion] Sour pickles

Travis Oliphant oliphant.travis at ieee.org
Mon Jun 26 16:32:09 CDT 2006

Keith Goodman wrote:
> Upgrading numpy and scipy from an April svn snapshot to yesterday's
> svn broke my code.
> To diagnose the problem I need to generate data in one version and
> load it in the other version.
> I did a search on how to save data in python and came up with pickle,
> or, actually, cpickle.
> But the format of the pickle is different between the two versions of
> numpy. I am unable to load in one version what I saved in the other
> version.
> when I pickle, for example, numpy.asmatrix([1,2,3]) as ASCII, numpy
> adds I1\n in two places compared with numpy
> Any advice?

The only thing that has changed in the Pickling code is the addition of 
a version number to the pickle.  However, this means that 
will not be able to read pickles, but will be able 
to read pickles.

This will be generally true.   You can expect to read old Pickles with 
NumPy but not necessarily new ones with an old version.

The other option is to use fromfile() and arr.tofile()  which will read 
and write raw data.   It's harder to use than pickle because no shape 
information is stored (it's just a raw binary file).


More information about the Numpy-discussion mailing list