[Numpy-discussion] Re: weird interaction: pickle, numpy, matplotlib.histHi

Tim Hochberg tim.hochberg at cox.net
Thu Apr 6 08:39:00 CDT 2006


Johannes Loehnert wrote:

>Hi,
>
>  
>
>>>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
>>>necessary.
>>>      
>>>
>>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.

Regards,

-tim







More information about the Numpy-discussion mailing list