Repository navigation
Make the bulk update helpers plain static functions - #1711
Merged
asvetlov merged 2 commits intoOct 6, 2026
Merged
Conversation
Drop ALWAYS_INLINE from _multidict_bulk() and _multidict_bulk_locked(), fold _md_to_dict_scan() into md_to_dict() with a runtime kind, and remove the _multidict_bulk inlining rule.
asvetlov
marked this pull request as ready for review
October 6, 2026 15:20
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?
Drops
ALWAYS_INLINE static inlinefrom_multidict_bulk()and_multidict_bulk_locked(), so__init__(),extend(),update()andmerge()share one out-of-line copy instead of each compiling its own._md_to_dict_scan()is folded intomd_to_dict(), which now picks the entry kind at runtime instead of specializing a copy per kind._multidict_clone_fast()was already plainstatic.The
_multidict_bulkrule intools/check_inlining.py(#1591, "one shared copy made subclass init 7-8% slower") is removed: the bulk paths changed a lot since then, and the cost measured now is far smaller.Callgrind, 3.14.7, instructions per operation, base vs this branch:
reinit_items_smallto_dict(), 200 entries, 150 keysctor_*includediter_items+2 Ir)reinit_items_smallisd.__init__(items)on an existing instance; construction itself goes through vectorcall and is unaffected.Are there changes in behavior for the user?
No.
Is it a substantial burden for the maintainers to support this?
No, it removes code.
Related issue number
N/A
Checklist
CONTRIBUTORS.txt(N/A)CHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Code (Claude Opus 5.5); to be reviewed by @asvetlov.
Agent run details (optional, for reviewers)
Tests:
pytest -qpassed on the C extension under 3.14.7 GIL (4089 passed), 3.14.7t FT (4074 passed) and 3.10 (4093 passed), and on the pure-Python build with--no-c-extensions(1610 passed).Inlining:
tools/check_inlining.pyok on 3.14.7 and 3.14.7t.Measurement:
benchmarks/callgrind_driver.py --include-multidict-only, base and branch trees in separate copies;to_dict()measured with a bracketed callgrind script (PYTHONHASHSEED=0, two loop counts differenced).