pickle format question

Jeff Epler jepler at unpythonic.net
Sat Oct 16 19:26:11 CEST 2004

Pickle output at least includes "\n" in addition to ASCII 32..126.

I believe that '\x7f' (ascii 127) will not be present in the output:
Strings are dumped in repr-like form, so ASCII 127 will be ouput as a
\x-sequence.  Numbers (floats, ints and longs) are also dumped in
repr-like form, and tuples and lists use just a few printable ASCII
characters in 32..126.

>>> string.printable 
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
>>> for c in pickle.dumps([(None), {1j:1L}, "\x7f", 1, 1.]):                   
...     if c not in string.printable: raise ValueError, ord(c)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20041016/d6580afc/attachment.pgp>

More information about the Python-list mailing list