Repository navigation
Commit 4a58ff7
gh-162350: Use AC vectorcall for _json.make_encoder
json.dumps() builds a new encoder on every call, so this is per-call
overhead for small payloads.
@vectorcall requires an immutable type: setting attributes on
_json.make_encoder now raises TypeError. Bad separators are now named
("argument 'key_separator'") instead of "argument 5".
pyperformance, PGO+LTO:
| Benchmark | main | branch |
|------------|:-------:|:---------------------:|
| json_dumps | 4.24 ms | 4.00 ms: 1.06x faster |
pyperf microbenchmarks, PGO+LTO:
| Benchmark | main | branch |
|------------------------------------------|:-------:|:---------------------:|
| json.dumps(1) | 456 ns | 409 ns: 1.12x faster |
| json.dumps(small, separators=(',', ':')) | 1.22 us | 1.13 us: 1.07x faster |
| json.dumps(small) | 850 ns | 794 ns: 1.07x faster |
| json.dumps(small, sort_keys=True) | 1.31 us | 1.23 us: 1.07x faster |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent 91c4c6b commit 4a58ff7
6 files changed
Lines changed: 215 additions & 17 deletions
File tree
- Include/internal
- Modules
- clinic
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
| |||
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| 464 | + | |
463 | 465 | | |
464 | 466 | | |
465 | 467 | | |
| |||
563 | 565 | | |
564 | 566 | | |
565 | 567 | | |
| 568 | + | |
566 | 569 | | |
567 | 570 | | |
568 | 571 | | |
| |||
596 | 599 | | |
597 | 600 | | |
598 | 601 | | |
| 602 | + | |
599 | 603 | | |
600 | 604 | | |
601 | 605 | | |
| |||
605 | 609 | | |
606 | 610 | | |
607 | 611 | | |
| 612 | + | |
608 | 613 | | |
609 | 614 | | |
610 | 615 | | |
| |||
638 | 643 | | |
639 | 644 | | |
640 | 645 | | |
| 646 | + | |
641 | 647 | | |
642 | 648 | | |
643 | 649 | | |
| |||
827 | 833 | | |
828 | 834 | | |
829 | 835 | | |
| 836 | + | |
830 | 837 | | |
831 | 838 | | |
832 | 839 | | |
| 840 | + | |
833 | 841 | | |
834 | 842 | | |
835 | 843 | | |
| |||
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.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
102 | | - | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
| |||
1306 | 1305 | | |
1307 | 1306 | | |
1308 | 1307 | | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1309 | 1324 | | |
1310 | | - | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1311 | 1330 | | |
1312 | | - | |
1313 | | - | |
1314 | 1331 | | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | 1332 | | |
1325 | 1333 | | |
1326 | 1334 | | |
| |||
2042 | 2050 | | |
2043 | 2051 | | |
2044 | 2052 | | |
| 2053 | + | |
2045 | 2054 | | |
2046 | 2055 | | |
2047 | 2056 | | |
2048 | 2057 | | |
2049 | 2058 | | |
2050 | 2059 | | |
2051 | 2060 | | |
2052 | | - | |
| 2061 | + | |
2053 | 2062 | | |
2054 | 2063 | | |
2055 | 2064 | | |
| |||
0 commit comments