[issue32037] Pickle 32-bit integers with protocol 0 as INT instead of LONG

Serhiy Storchaka report at bugs.python.org
Wed Nov 15 11:59:49 EST 2017


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

In Python 3 different opcodes are used for pickling integers with protocol 1 and higher. But pickling with protocol 0 always uses the LONG opcode. In Python all such integers are unpickled to the long instances.

Proposed PR makes integers that fit in a signed 32-bit integer be pickled with the INT opcode. This will decrease the size of a pickle (minus one byte 'L' per integer), speeds up pickling and unpickling, and makes these integers be unpickled to int instances in Python 2, that will save a memory.

----------
assignee: serhiy.storchaka
components: Library (Lib)
messages: 306285
nosy: alexandre.vassalotti, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Pickle 32-bit integers with protocol 0 as INT instead of LONG
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32037>
_______________________________________


More information about the Python-bugs-list mailing list