[issue12848] pickle.py treats 32bit lengths as signed, but _pickle.c as unsigned

Alexandre Vassalotti report at bugs.python.org
Tue Nov 6 23:46:27 CET 2012


Alexandre Vassalotti added the comment:

pickle.py is the buggy one here. Its use of the marshal module is really a hack. Plus, it is slower than both struct and int.from_bytes.

14:40:57 [~/cpython]$ ./python -m timeit "int.from_bytes(b'\xff\xff\xff\xff', 'big')"
1000000 loops, best of 3: 0.209 usec per loop
14:38:03 [~/cpython]$ ./python -m timeit -s "import struct" "struct.unpack('>I', b'\xff\xff\xff\xff')"
10000000 loops, best of 3: 0.147 usec per loop
14:37:44 [~/cpython]$ ./python -m timeit -s "import marshal" "marshal.loads(b'i'+b'\xff\xff\xff\xff')"
1000000 loops, best of 3: 0.236 usec per loop

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12848>
_______________________________________


More information about the Python-bugs-list mailing list