diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-16 07:44:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 07:44:43 (GMT) |
commit | 3daaafb700df45716bb55f3a293f88773baf3463 (patch) | |
tree | 72e6fe022b82ba7660e82f3561ef991e33a345dd /Lib/pickle.py | |
parent | 0a2abdfca2495291809855cf7dfc6721c9c962e3 (diff) | |
download | cpython-3daaafb700df45716bb55f3a293f88773baf3463.zip cpython-3daaafb700df45716bb55f3a293f88773baf3463.tar.gz cpython-3daaafb700df45716bb55f3a293f88773baf3463.tar.bz2 |
bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (#4407)
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index faa8fd7..350d4a4 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -674,7 +674,10 @@ class _Pickler: else: self.write(LONG4 + pack("<i", n) + encoded) return - self.write(LONG + repr(obj).encode("ascii") + b'L\n') + if -0x80000000 <= obj <= 0x7fffffff: + self.write(INT + repr(obj).encode("ascii") + b'\n') + else: + self.write(LONG + repr(obj).encode("ascii") + b'L\n') dispatch[int] = save_long def save_float(self, obj): |