Skip to content

Commit 7de2ab7

Browse files
cmaloneyclaude
andcommitted
pythongh-87613: Add vectorcall to bytearray.__init__ via Argument Clinic
Use the new @vectorcall decorator to generate a vectorcall constructor for bytearray, enabling the fast calling path without tuple/dict packing. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent d966263 commit 7de2ab7

File tree

2 files changed

+154
-2
lines changed

2 files changed

+154
-2
lines changed

Objects/bytearrayobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ bytearray_ass_subscript(PyObject *op, PyObject *index, PyObject *values)
903903
}
904904

905905
/*[clinic input]
906+
@vectorcall
906907
bytearray.__init__
907908
908909
source as arg: object = NULL
@@ -914,7 +915,7 @@ bytearray.__init__
914915
static int
915916
bytearray___init___impl(PyByteArrayObject *self, PyObject *arg,
916917
const char *encoding, const char *errors)
917-
/*[clinic end generated code: output=4ce1304649c2f8b3 input=1141a7122eefd7b9]*/
918+
/*[clinic end generated code: output=4ce1304649c2f8b3 input=24ddb84055f432dd]*/
918919
{
919920
Py_ssize_t count;
920921
PyObject *it;
@@ -2936,6 +2937,7 @@ PyTypeObject PyByteArray_Type = {
29362937
PyType_GenericAlloc, /* tp_alloc */
29372938
PyType_GenericNew, /* tp_new */
29382939
PyObject_Free, /* tp_free */
2940+
.tp_vectorcall = bytearray_vectorcall,
29392941
.tp_version_tag = _Py_TYPE_VERSION_BYTEARRAY,
29402942
};
29412943

Objects/clinic/bytearrayobject.c.h

Lines changed: 151 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)