This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hniksic
Recipients alexandre.vassalotti, benjamin.peterson, gvanrossum, hniksic, jcea, rhettinger
Date 2008-08-12.08:00:25
SpamBayes Score 2.2934459e-09
Marked as misclassified No
Message-id <1218528029.47.0.184037855532.issue2389@psf.upfronthosting.co.za>
In-reply-to
Content
Unfortunately dumping the internal representation of non-long arrays
won't work, for several reasons.  First, it breaks when porting pickles
between platforms of different endianness such as Intel and SPARC. 
Then, it ignores the considerable work put into correctly pickling
floats, including the support for IEEE 754 special values.  Finally, it
will break when unpickling Unicode character arrays pickled on different
Python versions -- wchar_t is 2 bytes wide on Windows, 4 bytes on Unix.

I believe pickling arrays to compact strings is the right approach on
the grounds of efficiency and I wouldn't change it.  We must only be
careful to pickle to a string with a portable representation of values.
 The straightforward way to do this is to pick a "standard" size for
types (much like the struct module does) and endianness and use it in
the pickled array.  Ints are simple, and the code for handling floats is
already there, for example _PyFloat_Pack8 used by cPickle.

Pickling arrays as lists is probably a decent workaround for the pending
release because it's backward and forward compatible (old pickles will
work as well as before and new pickles will be correctly read by old
Python versions), but for the next release I would prefer to handle this
the right way.  If there is agreement on this, I can start work on a
patch in the following weeks.
History
Date User Action Args
2008-08-12 08:00:29hniksicsetrecipients: + hniksic, gvanrossum, rhettinger, jcea, alexandre.vassalotti, benjamin.peterson
2008-08-12 08:00:29hniksicsetmessageid: <1218528029.47.0.184037855532.issue2389@psf.upfronthosting.co.za>
2008-08-12 08:00:28hniksiclinkissue2389 messages
2008-08-12 08:00:26hniksiccreate