mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Implement compact dict
Issue #27350: `dict` implementation is changed like PyPy. It is more compact and preserves insertion order. _PyDict_Dummy() function has been removed. Disable test_gdb: python-gdb.py is not updated yet to the new structure of compact dictionaries (issue #28023). Patch written by INADA Naoki.
This commit is contained in:
parent
d8b7770a0e
commit
742da040db
12 changed files with 793 additions and 569 deletions
|
@ -5116,12 +5116,14 @@ class SharedKeyTests(unittest.TestCase):
|
|||
a, b = A(), B()
|
||||
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
|
||||
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
|
||||
a.x, a.y, a.z, a.w = range(4)
|
||||
# Initial hash table can contain at most 5 elements.
|
||||
# Set 6 attributes to cause internal resizing.
|
||||
a.x, a.y, a.z, a.w, a.v, a.u = range(6)
|
||||
self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
|
||||
a2 = A()
|
||||
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
|
||||
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({}))
|
||||
b.u, b.v, b.w, b.t = range(4)
|
||||
b.u, b.v, b.w, b.t, b.s, b.r = range(6)
|
||||
self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({}))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue