Issue 25462: Avoid repeated hash calculation in C implementation of OrderedDict (original) (raw)
Issue25462
This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/69648
classification
Title: | Avoid repeated hash calculation in C implementation of OrderedDict | ||
---|---|---|---|
Type: | enhancement | Stage: | resolved |
Components: | Regular Expressions | Versions: | Python 3.6, Python 3.5 |
process
Status: | closed | Resolution: | fixed |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | Nosy List: | eric.snow, ezio.melotti, mrabarnett, python-dev, rhettinger, serhiy.storchaka | |
Priority: | normal | Keywords: | patch |
Created on 2015-10-22 18:15 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Files | |||
---|---|---|---|
File name | Uploaded | Description | Edit |
odict_knownhash.patch | serhiy.storchaka,2015-10-22 18:15 | review | |
odict_knownhash_2.patch | serhiy.storchaka,2015-11-06 11:23 | review |
Messages (6) | ||
---|---|---|
msg253343 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2015-10-22 18:15 |
There are private _PyDict_*_KnownHash functions that allow to avoid repeated hash calculation in complex operations with a dict. Proposed patch makes C implementation of OrderedDict to use these functions. It is not just an optimization, it makes some OrderedDict methods atomic (or almost atomic), that decreases a chance to desynchronize the linked list with the dict. That is why I suggest to commit the patch in 3.5. | ||
msg254182 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2015-11-06 10:18 |
Could you please make a review of this patch Eric? It is moved to separate issue because it is enough large and complex. | ||
msg254294 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2015-11-07 20:07 |
The patch looks correct, and it improves the integrity of the C implementation. | ||
msg254296 - (view) | Author: Eric Snow (eric.snow) * ![]() |
Date: 2015-11-07 20:22 |
I agree with Raymond. | ||
msg254603 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2015-11-13 13:19 |
New changeset 52ff0c00a404 by Serhiy Storchaka in branch '3.5': Issue #25462: The hash of the key now is calculated only once in most https://hg.python.org/cpython/rev/52ff0c00a404 New changeset 828c9b920532 by Serhiy Storchaka in branch 'default': Issue #25462: The hash of the key now is calculated only once in most https://hg.python.org/cpython/rev/828c9b920532 | ||
msg254604 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2015-11-13 13:20 |
Thank you Raymond and Eric. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:23 | admin | set | github: 69648 |
2015-11-13 13:21:16 | serhiy.storchaka | set | stage: commit review -> resolved |
2015-11-13 13:21:03 | serhiy.storchaka | set | status: open -> closedresolution: fixed |
2015-11-13 13:20:35 | serhiy.storchaka | set | messages: + |
2015-11-13 13:19:12 | python-dev | set | nosy: + python-devmessages: + |
2015-11-07 20:22:10 | eric.snow | set | messages: + stage: patch review -> commit review |
2015-11-07 20:07:46 | rhettinger | set | messages: + |
2015-11-06 11:23:33 | serhiy.storchaka | set | files: + odict_knownhash_2.patch |
2015-11-06 10🔞13 | serhiy.storchaka | set | messages: + |
2015-10-22 18:15:07 | serhiy.storchaka | create |