Repository navigation
Conversation
The parser allocated an empty dict for **kwargs when there were no keyword arguments. Pass NULL instead, like the caller does, and handle NULL in the impls that used the dict unconditionally. All **kwargs impls were audited: _csv and zoneinfo already accept NULL, and the rest (structseq and SimpleNamespace `__replace__`, _interpreters.new_config, atexit.register, SubElement) now check for it. atexit stores None, which the run loop already maps back to NULL. pyperf, PGO+LTO, `t = time.gmtime(0)`, `ns = SimpleNamespace(a=1)`: | Benchmark | main | this change | |---------------------------------|:------:|:---------------------:| | struct_time.`__replace__`() | 229 ns | 47.0 ns: 4.87x faster | | SimpleNamespace.`__replace__`() | 72.2 ns | 65.5 ns: 1.10x faster | Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmaloney
requested review from
AA-Turner,
ericsnowcurrently and
erlend-aasland
as code owners
November 5, 2026 07:03
msullivan
reviewed
Nov 5, 2026
Comment on lines
+1452
to
+1453
| # NULL when there are no keywords: no call allocates an empty dict. | ||
| return f"{self.parser_name} = Py_XNewRef(kwargs);\n" |
Contributor
There was a problem hiding this comment.
Is there anywhere to document the new behavior, to make sure this isn't a footgun?
Contributor
Author
There was a problem hiding this comment.
https://devguide.python.org/development-tools/clinic/ is all the docs and doesn't go into that much detail. For https://docs.python.org/3.13/c-api/call.html#c.vectorcallfunc it is documented as able to be NULL, so this to me is bringing AC parsers into that same state.
msullivan
approved these changes
Nov 5, 2026
Contributor
Author
|
@eendebakpt could you take a look at this one? This + the "support **kwargs in AC" that comes after enable using AC vectorcall for a speedup on most objects, in particular |
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.
The generated parser allocated an empty dict for **kwargs when there were no keyword arguments. Pass NULL instead, like the caller does, and handle NULL in the impls that used the dict unconditionally.
This is preparation work for supporting **kwargs in Argument Clinic Vectorcall where allocating a dict instead of passing NULL makes a significant performance impact.
All **kwargs impls were audited: _csv and zoneinfo already accept NULL, and the rest (structseq and SimpleNamespace
__replace__, _interpreters.new_config, atexit.register, SubElement) now check for it. atexit stores None, which the run loop already maps back to NULL.pyperf, PGO+LTO,
t = time.gmtime(0),ns = SimpleNamespace(a=1):__replace__()__replace__()