Repository navigation
Benchmark the shapes where an allocation is most of the work - #1556
Merged
asvetlov merged 2 commits intoSep 24, 2026
Merged
Conversation
asvetlov
force-pushed
the
claude/benchmark-small-mappings
branch
from
September 24, 2026 08:25
cfabc6a to
ffe7cb1
Compare
asvetlov
marked this pull request as ready for review
September 24, 2026 08:29
Contributor
|
Contributor
Comments Outside DiffThese findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1556 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 7001 7014 +13
Branches 610 610
=========================================
+ Hits 7001 7014 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
5 of 6 tasks
asvetlov
added a commit
that referenced
this pull request
Sep 24, 2026
<!-- Thank you for your contribution! --> ## What do these changes do? "What is measured" says every row uses a mapping of 200 keys, with `d.update(other)` as the only exception. Since #1556 that is no longer true: `cls()` builds an empty mapping and two rows use 20 items, so a reader comparing them against the 200-key rows would draw the wrong conclusion. This says which rows those are and why they differ. ## Are there changes in behavior for the user? No. Prose only; no measurement or table changes. ## Is it a substantial burden for the maintainers to support this? No. ## Related issue number Follows up #1556. ## Checklist - [x] I think the code is well written - [x] Unit tests for the changes exist — N/A, documentation only - [x] Documentation reflects the changes - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt` — N/A, already listed - [x] Add a new news fragment into the `CHANGES/` folder - [x] `make doc-spelling` passes and any new technical words are added to `docs/spelling_wordlist.txt` Drafted with Claude Opus 5; reviewed by @asvetlov.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
The registry measured every operation on a 200-item mapping. The
allocation an operation makes is a fixed cost, so at that size it was
divided across 200 entries and all but disappeared:
d.items()measured 1.7% faster under #1541 where it is in fact 46% faster, and
the shell pools looked marginal when they are not.
Six operations are added for the shapes where the allocation is most of
the work:
cls(),cls(items)andd.copy()at 20 items,d.items()and
iter(d)taken without being consumed, andProxy(d). The lastneeds a proxy type per implementation, so
Implgainsload_proxyandOperationaproxyflag, mirroring howistralready works.The generated tables in
docs/benchmark.rstare regenerated, so theirnumbers also move to current
master.Are there changes in behavior for the user?
No. Nothing outside
benchmarks/anddocs/changes.Is it a substantial burden for the maintainers to support this?
No. The new cases reuse the existing
Caseshape and the existingrunners;
callgrind_driver.py --self-checkcovers them.Related issue number
None.
Checklist
benchmarks/has no suite;--self-checkruns every cellCONTRIBUTORS.txt— N/A, already listedCHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtAgent run details (optional, for reviewers)
What the new cases say about the two shell-pool PRs, instructions per
operation, GIL build:
#1541 against its parent
130bd92:MultiDictCIMultiDictd.items()iter(d)for k in d, 200 keys#1542 against
51c75e4:MultiDictCIMultiDictcls()Proxy(d)d.copy(), 20 itemscls(items), 20 itemscls(items), 200 itemscallgrind_driver.py --self-checkpasses at 124 cells. Tables collectedon CPython 3.14.7 GIL and 3.14.7t,
PYTHONHASHSEED=0, client-requestbracketing, matching the environment the previous tables recorded.
Drafted with Claude Opus 5; reviewed by @asvetlov.