[Numpy-discussion] Re: weird interaction: pickle, numpy, matplotlib.histHi
tim.hochberg at cox.net
Thu Apr 6 08:39:00 CDT 2006
Johannes Loehnert wrote:
>>>But, this brings up the point that currently the pickled raw-data which
>>>is read-in as a string by Python is used as the memory for the new array
>>>(i.e. the string memory is "stolen"). This should work. The fact
>>>that it didn't with sort was a bug that is now fixed in SVN. However,
>>>operations on out-of-byte-order arrays will always be slower. Thus,
>>>perhaps on pickle read the data should be copied to native byte-order if
>>Yes, I think that converting directly to native byteorder in
>>unpickling time would be the best.
>If you stored your data in wrong byte order for some odd reason (maybe you use
>a library that requires a certain byte order), then you would want pickle to
>deliver the data back exactly as stored. I think this should be made a user
>option in some way, although I do not know a good place for it right now.
If this is really something we want to do, it seems that the "correct"
solution is to have a different dtype when an object defaults to a given
byte order than when it is forced to that byte order. Pickle could keep
track of that and do the right thing on loading. For example, "<!d4"
could mean that the byte order was explicitly specified, so leave it
alone. I don't know if this is worth the effort though.
More information about the Numpy-discussion