Skip to content

Commit

Permalink
bpo-37207: enable vectorcall for type.__call__ (pythonGH-14588)
Browse files Browse the repository at this point in the history
Base PR for other PRs that want to play with `type.__call__` such as python#13930 and python#14589.

The author is really @markshannon I just made the PR.


https://bugs.python.org/issue37207



Automerge-Triggered-By: @encukou
  • Loading branch information
jdemeyer authored and miss-islington committed Aug 15, 2019
1 parent 40dad95 commit 37806f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 3 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand Down

0 comments on commit 37806f4

Please sign in to comment.