[PYTHON MATRIX-SIG] pickle error on Win95
Guido van Rossum
guido@CNRI.Reston.VA.US
Wed, 20 Mar 1996 10:27:15 -0500
> I've been waiting for somebody to notice this and properly castigate
> me for violating the beauty of pickle's text-only format.
>
> There are some major size and speed savings to be realized by dumping
> large arrays in a binary format. Since dumping 1 MB arrays to disk is
> not all that uncommon, these things are unfortunately an issue.
Agreed. For large strings, I was going to add this (eventually) as a
speed up extension as well.
> This is the first time that anybody's noticed problems with the binary
> format, and it seems a simple enough matter to add warnings that
> matrices should only be pickled to binary format files. Other than
> this, I've found the binary format to work quite well for archiving
> arbitrary objects that contain matrices across many platforms
> (big/little endian) and even for passing these objects across sockets.
You must've patched the pickle module, right?
> Anybody know a way I can add a check to the matrix pickling routines
> to determine if they're writing to/reading from a binary format file
> and raise an exception otherwise?
That's easy. A file object has an attribute 'mode' which is the
read/write open mode. Of course, pickle can also be used on pseudo
file objects (like StringIO) which don't have this attribute.
--Guido van Rossum <guido@CNRI.Reston.VA.US>
URL: <http://www.python.org/~guido/>
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================