Repository navigation
Commit 82837ae
gh-87613: Pass NULL for an empty **kwargs in Argument Clinic
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>1 parent aaaf61c commit 82837ae
15 files changed
Lines changed: 45 additions & 172 deletions
File tree
- Lib/test
- Modules
- clinic
- Objects
- clinic
- Tools/clinic/libclinic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5708 | 5708 | | |
5709 | 5709 | | |
5710 | 5710 | | |
5711 | | - | |
| 5711 | + | |
5712 | 5712 | | |
5713 | 5713 | | |
5714 | 5714 | | |
| |||
5721 | 5721 | | |
5722 | 5722 | | |
5723 | 5723 | | |
5724 | | - | |
| 5724 | + | |
5725 | 5725 | | |
5726 | 5726 | | |
5727 | 5727 | | |
| |||
5732 | 5732 | | |
5733 | 5733 | | |
5734 | 5734 | | |
5735 | | - | |
5736 | | - | |
| 5735 | + | |
| 5736 | + | |
5737 | 5737 | | |
5738 | 5738 | | |
5739 | 5739 | | |
5740 | 5740 | | |
5741 | 5741 | | |
5742 | 5742 | | |
5743 | | - | |
5744 | | - | |
| 5743 | + | |
| 5744 | + | |
5745 | 5745 | | |
5746 | 5746 | | |
5747 | 5747 | | |
| |||
5753 | 5753 | | |
5754 | 5754 | | |
5755 | 5755 | | |
5756 | | - | |
| 5756 | + | |
5757 | 5757 | | |
5758 | 5758 | | |
5759 | 5759 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
647 | | - | |
| 647 | + | |
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
831 | | - | |
| 831 | + | |
832 | 832 | | |
833 | 833 | | |
834 | 834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments