diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-13 18:15:19 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-08-13 18:15:19 (GMT) |
commit | 3c7e928098d874d82f1069fca640d20afca84c02 (patch) | |
tree | ffa38bccd38c29217f7f37656b0a9a523c4bd46c /Lib/test/pickletester.py | |
parent | 780199e6a367a98e98ff69750ad24916a0888b9f (diff) | |
download | cpython-3c7e928098d874d82f1069fca640d20afca84c02.zip cpython-3c7e928098d874d82f1069fca640d20afca84c02.tar.gz cpython-3c7e928098d874d82f1069fca640d20afca84c02.tar.bz2 |
Issue #12744: Fix inefficient representation of integers
between 2**31 and 2**63 on systems with a 64-bit C "long".
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r-- | Lib/test/pickletester.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index f90d348..ad15fe8 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -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): |