Message141971
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 |
|
Date |
User |
Action |
Args |
2011-08-12 16:26:24 | pitrou | set | recipients:
+ pitrou |
2011-08-12 16:26:23 | pitrou | set | messageid: <1313166383.93.0.380939327922.issue12744@psf.upfronthosting.co.za> |
2011-08-12 16:26:23 | pitrou | link | issue12744 messages |
2011-08-12 16:26:22 | pitrou | create | |
|