@@ -688,18 +688,31 @@ and :c:type:`PyType_Type` effectively act as defaults.)
688
688
689
689
Any class that sets ``_Py_TPFLAGS_HAVE_VECTORCALL `` must also set
690
690
:c:member: `~PyTypeObject.tp_call ` and make sure its behaviour is consistent
691
- with the *vectorcallfunc * function. This can be done by setting * tp_call * to
692
- ``PyVectorcall_Call ``:
691
+ with the *vectorcallfunc * function.
692
+ This can be done by setting * tp_call * to ``PyVectorcall_Call ``:
693
693
694
694
.. c :function :: PyObject *PyVectorcall_Call (PyObject *callable, PyObject *tuple, PyObject *dict)
695
695
696
696
Call *callable *'s *vectorcallfunc * with positional and keyword
697
697
arguments given in a tuple and dict, respectively.
698
698
699
+ This function is intended to be used in the ``tp_call `` slot.
700
+ It does not fall back to ``tp_call `` and it currently does not check the
701
+ ``_Py_TPFLAGS_HAVE_VECTORCALL `` flag.
702
+ To call an object, use one of the :c:func: `PyObject_Call <PyObject_Call> `
703
+ functions instead.
704
+
699
705
.. note ::
700
706
701
- The semantics of slot are provisional and expected to be finalized
702
- in Python 3.9.
707
+ It is not recommended for :ref: `heap types <heap-types >` to implement
708
+ the vectorcall protocol.
709
+ When a user sets ``__call__ `` in Python code, only ``tp_call `` is updated,
710
+ possibly making it inconsistent with the vectorcall function.
711
+
712
+ .. note ::
713
+
714
+ The semantics of the ``tp_vectorcall_offset `` slot are provisional and
715
+ expected to be finalized in Python 3.9.
703
716
If you use vectorcall, plan for updating your code for Python 3.9.
704
717
705
718
.. versionchanged :: 3.8
@@ -709,14 +722,13 @@ and :c:type:`PyType_Type` effectively act as defaults.)
709
722
710
723
**Inheritance: **
711
724
712
- This field is inherited by *static * subtypes together with
713
- :c:member: `~PyTypeObject.tp_call `: a subtype inherits both
714
- :c:member: `~PyTypeObject.tp_vectorcall_offset ` and
715
- :c:member: `~PyTypeObject.tp_call ` from its base type when the subtype’s
716
- :c:member: `~PyTypeObject.tp_call ` and :c:member: `~PyTypeObject.tp_vectorcall_offset `
717
- are both NULL.
725
+ This field is inherited by subtypes together with
726
+ :c:member: `~PyTypeObject.tp_call `: a subtype inherits
727
+ :c:member: `~PyTypeObject.tp_vectorcall_offset ` from its base type when
728
+ the subtype’s :c:member: `~PyTypeObject.tp_call ` is NULL.
718
729
719
- `Heap types `_ never inherit :c:member: `~PyTypeObject.tp_vectorcall_offset `.
730
+ Note that `heap types `_ (including subclasses defined in Python) do not
731
+ inherit the :const :`_Py_TPFLAGS_HAVE_VECTORCALL` flag.
720
732
721
733
722
734
.. c:member:: getattrfunc PyTypeObject.tp_getattr
@@ -1148,6 +1160,15 @@ and :c:type:`PyType_Type` effectively act as defaults.)
1148
1160
This bit is set when the class implements the vectorcall protocol.
1149
1161
See :c:member: `~PyTypeObject.tp_vectorcall_offset ` for details.
1150
1162
1163
+ **Inheritance: **
1164
+
1165
+ This bit is set on *static * subtypes if ``tp_flags `` is not overridden:
1166
+ a subtype inherits ``_Py_TPFLAGS_HAVE_VECTORCALL `` from its base type
1167
+ when the subtype’s :c:member: `~PyTypeObject.tp_call ` is NULL
1168
+ and the subtype's ``Py_TPFLAGS_HEAPTYPE `` is not set.
1169
+
1170
+ `Heap types `_ do not inherit ``_Py_TPFLAGS_HAVE_VECTORCALL ``.
1171
+
1151
1172
.. note ::
1152
1173
1153
1174
This flag is provisional and expected to become public in Python 3.9,
0 commit comments