mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #12744: Fix inefficient representation of integers
between 2**31 and 2**63 on systems with a 64-bit C "long".
This commit is contained in:
parent
780199e6a3
commit
3c7e928098
3 changed files with 14 additions and 1 deletions
|
@ -1118,6 +1118,16 @@ class AbstractPickleTests(unittest.TestCase):
|
|||
empty = self.loads(b'\x80\x03U\x00q\x00.', encoding='koi8-r')
|
||||
self.assertEqual(empty, '')
|
||||
|
||||
def test_int_pickling_efficiency(self):
|
||||
# Test compacity of int representation (see issue #12744)
|
||||
for proto in protocols:
|
||||
sizes = [len(self.dumps(2**n, proto)) for n in range(70)]
|
||||
# the size function is monotonous
|
||||
self.assertEqual(sorted(sizes), sizes)
|
||||
if proto >= 2:
|
||||
self.assertLessEqual(sizes[-1], 14)
|
||||
|
||||
|
||||
# Test classes for reduce_ex
|
||||
|
||||
class REX_one(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue