Repository navigation
Commit ee77d72
committed
gh-158816: Skip redundant hash table probe when deleting from split dicts
delitem_common() unconditionally called lookdict_index() to locate the index slot in dk_indices that points at the entry being removed.
That slot is only used by the combined branch, to overwrite it with DKIX_DUMMY. In split tables the whole probe sequence was redundant work.
Move the call into the combined branch and drop the now-pointless assert() for split tables.
Microbenchmark (free-threaded build, -Og, no PGO; deleting keys from materialized instance dicts; medians over 12 alternating runs):
del d[k] 71.2 -> 69.2 ns/op (-2.8%)
d.pop(k) 98.9 -> 96.1 ns/op (-2.8%)
colliding hashes 78.0 -> 74.4 ns/op (-4.6%)
clang still does not sink the call into the branch at -O3 -DNDEBUG, so this is not specific to the local
-Og build.
test_dict, test_dictviews and test_dictcomps pass.1 parent 9d22a53 commit ee77d72
2 files changed
Lines changed: 6 additions & 3 deletions
File tree
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2938 | 2938 | | |
2939 | 2939 | | |
2940 | 2940 | | |
2941 | | - | |
2942 | | - | |
2943 | | - | |
2944 | 2941 | | |
2945 | 2942 | | |
2946 | 2943 | | |
| |||
2951 | 2948 | | |
2952 | 2949 | | |
2953 | 2950 | | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
2954 | 2954 | | |
2955 | 2955 | | |
2956 | 2956 | | |
| |||
0 commit comments