You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Skip useless hash table probe when deleting from split dicts #158816
delitem_common() currently calls lookdict_index() before checking whether the dictionary is combined or split.
For split dictionaries, the returned hash-table slot is not used. Therefore, the probe performed by lookdict_index() is redundant for split-table deletions.
I propose moving lookdict_index() into the combined-table branch avoiding a full probe sequence for every deletion from a split dictionary.
Benchmark
Measured with a free-threaded build, -Og, without PGO. The benchmark deletes keys from materialized instance dictionaries; medians over 12 alternating runs:
before after change
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%
Combined-table deletions are unchanged.
Clang also does not sink the lookdict_index() call into the branch at -O3 -DNDEBUG, so the improvement is not specific to the local -Og build.
Activity
gh-158816: Skip useless hash table probe when deleting from split dic…