[Numpy-discussion] Bytes Object and Pickling

Scott Gilbert xscottg at yahoo.com
Fri Mar 25 22:59:01 CST 2005


--- Travis Oliphant <oliphant at ee.byu.edu> wrote:
> 
> I think pickling could be handled efficiently with a single new opcode 
> very similar to a string but instead creating a bytes object on 
> unpickling.   Then, an array could use the memory of that bytes object 
> (instead of creating it's own and copying).   This would be very easy to 
> handle. 
>

I agree that this is the easy and *right* way to add pickling of the "bytes
object".

However, several years ago, Guido imposed an additional constraint.  He
wanted the "bytes objects" to unpickle as "string objects" on older
versions of Python that didn't know about the new "bytes type".  His
reasoning was that pickling is used to communicate between different
versions of Python, and the older ones would die ungracefully when exposed
to the new type.

Perhaps his position would be different now.  He has made added a new
Pickling protocol since then, and that had to break backwards compatibility
somewhere.

Cheers,
    -Scott





More information about the Numpy-discussion mailing list