[Numpy-discussion] Sour pickles

Travis Oliphant oliphant.travis at ieee.org
Mon Jun 26 17:32:09 EDT 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
> 0.9.9.2677 adds I1\n in two places compared with numpy 0.9.7.2416.
>
> 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 0.9.7.2416 
will not be able to read 0.9.9.2677 pickles, but 0.9.9.2677 will be able 
to read 0.9.7.2416 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).


-Travis





More information about the NumPy-Discussion mailing list