Skip to content

Commit 37806f4

Browse files
jdemeyermiss-islington
authored andcommitted
bpo-37207: enable vectorcall for type.__call__ (GH-14588)
Base PR for other PRs that want to play with `type.__call__` such as #13930 and #14589. The author is really @markshannon I just made the PR. https://bugs.python.org/issue37207 Automerge-Triggered-By: @encukou
1 parent 40dad95 commit 37806f4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The vectorcall protocol is now enabled for ``type`` objects: set
2+
``tp_vectorcall`` to a vectorcall function to be used instead of ``tp_new``
3+
and ``tp_init`` when calling the class itself.

Objects/typeobject.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3614,7 +3614,7 @@ PyTypeObject PyType_Type = {
36143614
sizeof(PyHeapTypeObject), /* tp_basicsize */
36153615
sizeof(PyMemberDef), /* tp_itemsize */
36163616
(destructor)type_dealloc, /* tp_dealloc */
3617-
0, /* tp_vectorcall_offset */
3617+
offsetof(PyTypeObject, tp_vectorcall), /* tp_vectorcall_offset */
36183618
0, /* tp_getattr */
36193619
0, /* tp_setattr */
36203620
0, /* tp_as_async */
@@ -3629,7 +3629,8 @@ PyTypeObject PyType_Type = {
36293629
(setattrofunc)type_setattro, /* tp_setattro */
36303630
0, /* tp_as_buffer */
36313631
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
3632-
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS, /* tp_flags */
3632+
Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS |
3633+
_Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */
36333634
type_doc, /* tp_doc */
36343635
(traverseproc)type_traverse, /* tp_traverse */
36353636
(inquiry)type_clear, /* tp_clear */

0 commit comments

Comments
 (0)