Repository navigation
Commit 84121e4
pythongh-87613: Use the AC vectorcall for bytes and bytearray
Neither type had a tp_vectorcall before, so every bytes() and
bytearray() call went through _PyObject_MakeTpCall(): an args tuple
(plus a kwargs dict for keyword calls) built on the way in to
type_call(). Add @vectorcall to bytes.__new__ and bytearray.__init__
and install the generated parsers in the two type objects.
bytearray is the first non-test type to use the @vectorcall __init__
path, which allocates through tp_new and then calls the __init__ impl,
so bytearray_new() still installs ob_bytes_object.
Error messages are unchanged: both types are positional-or-keyword only,
so the generated vectorcall handles up to three positional arguments
inline and hands everything else (keywords, too many arguments) to the
same helper the tp_new/tp_init slot uses. Extend the vectorcall
slot-parity test to cover both.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ab0b393 commit 84121e4
5 files changed
Lines changed: 187 additions & 16 deletions
File tree
- Lib/test
- Objects
- clinic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5592 | 5592 | | |
5593 | 5593 | | |
5594 | 5594 | | |
5595 | | - | |
5596 | | - | |
| 5595 | + | |
| 5596 | + | |
5597 | 5597 | | |
5598 | 5598 | | |
5599 | 5599 | | |
5600 | | - | |
| 5600 | + | |
| 5601 | + | |
| 5602 | + | |
| 5603 | + | |
5601 | 5604 | | |
5602 | 5605 | | |
5603 | 5606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
| 981 | + | |
981 | 982 | | |
982 | 983 | | |
983 | 984 | | |
| |||
989 | 990 | | |
990 | 991 | | |
991 | 992 | | |
992 | | - | |
| 993 | + | |
993 | 994 | | |
994 | 995 | | |
995 | 996 | | |
| |||
3015 | 3016 | | |
3016 | 3017 | | |
3017 | 3018 | | |
| 3019 | + | |
3018 | 3020 | | |
3019 | 3021 | | |
3020 | 3022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2879 | 2879 | | |
2880 | 2880 | | |
2881 | 2881 | | |
| 2882 | + | |
2882 | 2883 | | |
2883 | 2884 | | |
2884 | 2885 | | |
| |||
2891 | 2892 | | |
2892 | 2893 | | |
2893 | 2894 | | |
2894 | | - | |
| 2895 | + | |
2895 | 2896 | | |
2896 | 2897 | | |
2897 | 2898 | | |
| |||
3277 | 3278 | | |
3278 | 3279 | | |
3279 | 3280 | | |
| 3281 | + | |
3280 | 3282 | | |
3281 | 3283 | | |
3282 | 3284 | | |
| |||
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