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.

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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2015-11-07 20:22
I agree with Raymond.
msg254603 - (view) Author: Roundup Robot (python-dev) (Python triager) 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) * (Python committer) Date: 2015-11-13 13:20
Thank you Raymond and Eric.
History
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69648
2015-11-13 13:21:16serhiy.storchakasetstage: commit review -> resolved
2015-11-13 13:21:03serhiy.storchakasetstatus: open -> closed
resolution: fixed
2015-11-13 13:20:35serhiy.storchakasetmessages: + msg254604
2015-11-13 13:19:12python-devsetnosy: + python-dev
messages: + msg254603
2015-11-07 20:22:10eric.snowsetmessages: + msg254296
stage: patch review -> commit review
2015-11-07 20:07:46rhettingersetmessages: + msg254294
2015-11-06 11:23:33serhiy.storchakasetfiles: + odict_knownhash_2.patch
2015-11-06 10:18:13serhiy.storchakasetmessages: + msg254182
2015-10-22 18:15:07serhiy.storchakacreate