In the old version of python, for the structure of the dictionary, why the hash table will become more and more sparse as the value increases?

Viewed 23

The hash table structure of older versions of Python is as follows:

--+-------------------------------+
  |    (hash)     (key)   (value)
--+-------------------------------+
0 |    hash0      key0    value0
--+-------------------------------+
1 |    hash1      key1    value1
--+-------------------------------+
2 |    hash2      key2    value2
--+-------------------------------+
. |           ...
__+_______________________________+

As the hash table expands, it becomes more and more sparse. For example, let's say I have a dictionary like this:

{'name': 'mike', 'dob': '1999-01-01', 'gender': 'male'}

then it will be stored as something like this:

entries = [
['--', '--', '--']
[-230273521, 'dob', '1999-01-01'],
['--', '--', '--'],
['--', '--', '--'],
[1231236123, 'name', 'mike'],
['--', '--', '--'],
[9371539127, 'gender', 'male']
]
0 Answers
Related