classification
Title: Pickle 32-bit integers with protocol 0 as INT instead of LONG
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: alexandre.vassalotti, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-11-15 16:59 by serhiy.storchaka, last changed 2017-11-16 07:45 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4407 merged serhiy.storchaka, 2017-11-15 17:07
Messages (2)
msg306285 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-15 16:59
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.
msg306342 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-16 07:44
New changeset 3daaafb700df45716bb55f3a293f88773baf3463 by Serhiy Storchaka in branch 'master':
bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (#4407)
https://github.com/python/cpython/commit/3daaafb700df45716bb55f3a293f88773baf3463
History
Date User Action Args
2017-11-16 07:45:07serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-11-16 07:44:45serhiy.storchakasetmessages: + msg306342
2017-11-15 17:07:49serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request4356
2017-11-15 16:59:49serhiy.storchakacreate