Repository navigation
Benchmark re-initializing a populated multidict - #1620
Merged
Merged
Conversation
Add reinit_items and reinit_clone operations, at 20 and 200 items, to the benchmark registry, and matching CodSpeed benchmarks. The ctor_* rows always construct a fresh object, so they never measured __init__ replacing a live table.
asvetlov
marked this pull request as ready for review
September 28, 2026 07:55
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1620 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 44 44
Lines 8268 8292 +24
Branches 703 703
=========================================
+ Hits 8268 8292 +24
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:
|
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?
Adds
reinit_items(d.__init__(items)) andreinit_clone(d.__init__(other)withotherof the same kind, themd_clone_from_ht()path) tobenchmarks/operations.py, each at 200 and 20 items, plus four matching CodSpeed benchmarks. The existingctor_*rows always build a fresh object whose table is empty, so replacing a live table (_md_install_keys(), #1619) was never measured; #1619 needed a one-off script.The target stays populated after each call, so the setup hands back the same object and nothing is rebuilt inside the timed region. The rows are multidict-only:
dict.__init__on a live dict updates rather than replaces. Multidict-only rows are not rendered intodocs/benchmark.rst, so the tables keep their shape and are not regenerated; the exclusion paragraph gained one sentence saying why re-initializing is left out. The CodSpeed tests carry no shard mark and run in shard 1 next to thecreate_*benchmarks; recent runs show the two shards within a few percent of each other on both builds.Are there changes in behavior for the user?
No.
Is it a substantial burden for the maintainers to support this?
No; four rows in the registry and four CodSpeed tests following the existing patterns.
Related issue number
Follow-up to #1619.
Checklist
callgrind_driver.py --self-checkasserts the re-initialized size)CONTRIBUTORS.txtN/ACHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Code (Claude Opus 5.5); reviewed by @asvetlov.
Agent run details (optional, for reviewers)
New rows, instructions per operation,
callgrind_driver.py --include-multidict-only, CPython 3.14.7,PYTHONHASHSEED=0, bracketed counting, drift 0:MultiDictCIMultiDictMultiDictCIMultiDictreinit_itemsreinit_items_smallreinit_clonereinit_clone_smallFor comparison,
ctor_itemsis 44,850 / 55,930 (GIL) and 67,679 / 78,106 (FT);copyis 25,472 / 25,612 (GIL) and 29,063 / 29,150 (FT).Tests:
pytest -qpassed on 3.14.7 GIL (2893 passed) and 3.14.7t FT (2881 passed) with the C extension;MULTIDICT_NO_EXTENSIONS=1 pytest -q --no-c-extensionspassed from a clean tree copy (1356 passed); the reinit CodSpeed tests pass on 3.10 pure Python.Self-check:
callgrind_driver.py --self-checkpassed on both builds (140 cells).Lint: pre-commit on the changed files and
make doc-spellingpassed.