mirror of
https://github.com/python/cpython.git
synced 2025-08-22 01:35:16 +00:00
bpo-46845: Reduce dict size when all keys are Unicode (GH-31564)
This commit is contained in:
parent
21099fc064
commit
9833bb91e4
9 changed files with 884 additions and 491 deletions
|
@ -787,12 +787,6 @@ class PyDictObjectPtr(PyObjectPtr):
|
|||
def _get_entries(keys):
|
||||
dk_nentries = int(keys['dk_nentries'])
|
||||
dk_size = 1<<int(keys['dk_log2_size'])
|
||||
try:
|
||||
# <= Python 3.5
|
||||
return keys['dk_entries'], dk_size
|
||||
except RuntimeError:
|
||||
# >= Python 3.6
|
||||
pass
|
||||
|
||||
if dk_size <= 0xFF:
|
||||
offset = dk_size
|
||||
|
@ -805,7 +799,10 @@ class PyDictObjectPtr(PyObjectPtr):
|
|||
|
||||
ent_addr = keys['dk_indices'].address
|
||||
ent_addr = ent_addr.cast(_type_unsigned_char_ptr()) + offset
|
||||
ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
|
||||
if int(keys['dk_kind']) == 0: # DICT_KEYS_GENERAL
|
||||
ent_ptr_t = gdb.lookup_type('PyDictKeyEntry').pointer()
|
||||
else:
|
||||
ent_ptr_t = gdb.lookup_type('PyDictUnicodeEntry').pointer()
|
||||
ent_addr = ent_addr.cast(ent_ptr_t)
|
||||
|
||||
return ent_addr, dk_nentries
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue