From cc56d32799cc83c1172f29c007f3ec07be230ffc Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Mon, 1 Apr 2019 17:58:49 +0100 Subject: [PATCH 1/2] bpo-37207: enable vectorcall for type.__call__ --- Objects/typeobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 3b9a537936a332..b828f79382f4dc 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3614,7 +3614,7 @@ PyTypeObject PyType_Type = { sizeof(PyHeapTypeObject), /* tp_basicsize */ sizeof(PyMemberDef), /* tp_itemsize */ (destructor)type_dealloc, /* tp_dealloc */ - 0, /* tp_vectorcall_offset */ + offsetof(PyTypeObject, tp_vectorcall), /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ @@ -3629,7 +3629,8 @@ PyTypeObject PyType_Type = { (setattrofunc)type_setattro, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_TYPE_SUBCLASS | + _Py_TPFLAGS_HAVE_VECTORCALL, /* tp_flags */ type_doc, /* tp_doc */ (traverseproc)type_traverse, /* tp_traverse */ (inquiry)type_clear, /* tp_clear */ From fead5afb7dcd825cc8d7bfb57c4d45df75235a72 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Sun, 7 Jul 2019 10:37:13 +0200 Subject: [PATCH 2/2] bpo-37207: add NEWS --- .../NEWS.d/next/C API/2019-07-07-10-37-07.bpo-37207.SlVNky.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/C API/2019-07-07-10-37-07.bpo-37207.SlVNky.rst diff --git a/Misc/NEWS.d/next/C API/2019-07-07-10-37-07.bpo-37207.SlVNky.rst b/Misc/NEWS.d/next/C API/2019-07-07-10-37-07.bpo-37207.SlVNky.rst new file mode 100644 index 00000000000000..8df76614a0d733 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-07-07-10-37-07.bpo-37207.SlVNky.rst @@ -0,0 +1,3 @@ +The vectorcall protocol is now enabled for ``type`` objects: set +``tp_vectorcall`` to a vectorcall function to be used instead of ``tp_new`` +and ``tp_init`` when calling the class itself.