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: Optimize dict.popitem() & insert use case.
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.10
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: methane
Priority: normal Keywords: patch

Created on 2020-10-31 00:36 by methane, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23054 closed methane, 2020-10-31 00:50
Messages (2)
msg380022 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-10-31 00:36
PyDict_DelItem stores DUMMY entry in the hash table. Without DUMMY, collision chain will be broken so proving will be not working.

But `dict.popitem()` returns the last item in the insertion order. The item must be the last item of collision chain too.
So `dict.popitem()` can use EMPTY entry instead of DUMMY, and reduce dict resizing.
msg380036 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-10-31 02:45
> But `dict.popitem()` returns the last item in the insertion order. The item must be the last item of collision chain too.

This assumption was wrong. Inserting new item may overwrite dummy entry. In this case, the last item in the middle of collision chain.
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86382
2020-10-31 02:45:10methanesetstatus: open -> closed
resolution: rejected
messages: + msg380036

stage: patch review -> resolved
2020-10-31 00:50:47methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request21973
2020-10-31 00:36:15methanecreate