-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-44206: Add a version number to dictionary keys #26333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sion is 0 before modification of a key.
Skipping news, as this is strictly internal. |
3cfccd7
to
0088371
Compare
Objects/dictobject.c
Outdated
|
||
CHECK(0 <= mp->ma_used && mp->ma_used <= usable); | ||
CHECK(IS_POWER_OF_2(keys->dk_size)); | ||
CHECK(IS_POWER_OF_2(DK_SIZE(keys))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is now redundant.
Performance results |
Objects/dict-common.h
Outdated
typedef enum { | ||
DICT_KEYS_GENERAL = 0, | ||
DICT_KEYS_UNICODE = 1, | ||
DICT_KEYS_UNICODE_NO_DUMMY = 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_Py_dict_lookup()
don't have specialized case for DICT_KEYS_UNICODE_NO_DUMMY. Can we delete this kind?
This kind is used only here.
Line 1226 in a316f34
else if (mp->ma_keys->dk_kind == DICT_KEYS_UNICODE) { |
But it can be replaced with mp->ma_used > mp->ma_keys->dk_nentries
.
python/cpython#26333 changed the way the size of the hash table is stored: instead of storing the actual value, dict now saves a log2 of that, which allowed to change the data type of the corresponding struct field from Py_ssize_t to uint8_t making all dict objects more compact.
Apart from adding a version number, this PR also:
I'll need to run pyperformance before merging, in case this slows things downs.
https://bugs.python.org/issue44206