Skip to content

Commit f5c7b7c

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

File tree

2 files changed

+142
-2
lines changed

2 files changed

+142
-2
lines changed

Objects/bytesobject.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,7 @@ static PyObject *
28592859
bytes_subtype_new(PyTypeObject *, PyObject *);
28602860

28612861
/*[clinic input]
2862+
@vectorcall
28622863
@classmethod
28632864
bytes.__new__ as bytes_new
28642865
@@ -2871,7 +2872,7 @@ bytes.__new__ as bytes_new
28712872
static PyObject *
28722873
bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding,
28732874
const char *errors)
2874-
/*[clinic end generated code: output=1e0c471be311a425 input=f0a966d19b7262b4]*/
2875+
/*[clinic end generated code: output=1e0c471be311a425 input=b0248d22e221a095]*/
28752876
{
28762877
PyObject *bytes;
28772878
PyObject *func;
@@ -3248,6 +3249,7 @@ PyTypeObject PyBytes_Type = {
32483249
bytes_alloc, /* tp_alloc */
32493250
bytes_new, /* tp_new */
32503251
PyObject_Free, /* tp_free */
3252+
.tp_vectorcall = bytes_vectorcall,
32513253
.tp_version_tag = _Py_TYPE_VERSION_BYTES,
32523254
};
32533255

Objects/clinic/bytesobject.c.h

Lines changed: 139 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)