New submission from Antoine Pitrou <pit...@free.fr>: On a 64-bit Linux machine (where C `long` is 64 bits):
>>> len(pickle.dumps(2**30)) 8 >>> len(pickle.dumps(2**31)) 16 >>> len(pickle.dumps(2**62)) 25 >>> len(pickle.dumps(2**63)) 14 This is because the old text protocol is used when the integer can fit in a C long but not in 4 bytes: >>> pickletools.dis(pickle.dumps(2**62)) 0: \x80 PROTO 3 2: L LONG 4611686018427387904 24: . STOP highest protocol among opcodes = 2 >>> pickletools.dis(pickle.dumps(2**63)) 0: \x80 PROTO 3 2: \x8a LONG1 9223372036854775808 13: . STOP highest protocol among opcodes = 2 ---------- components: Library (Lib) messages: 141971 nosy: pitrou priority: normal severity: normal status: open title: inefficient pickling of long integers on 64-bit builds type: resource usage versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12744> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com