@@ -35,17 +35,11 @@ To call an object, use :c:func:`PyObject_Call` or other
35
35
The Vectorcall Protocol
36
36
-----------------------
37
37
38
- .. versionadded :: 3.8
38
+ .. versionadded :: 3.9
39
39
40
40
The vectorcall protocol was introduced in :pep: `590 ` as an additional protocol
41
41
for making calls more efficient.
42
42
43
- .. warning ::
44
-
45
- The vectorcall API is provisional and expected to become public in
46
- Python 3.9, with a different names and, possibly, changed semantics.
47
- If you use the it, plan for updating your code for Python 3.9.
48
-
49
43
As rule of thumb, CPython will prefer the vectorcall for internal calls
50
44
if the callable supports it. However, this is not a hard rule.
51
45
Additionally, some third-party extensions use *tp_call * directly
@@ -69,7 +63,7 @@ the arguments to an args tuple and kwargs dict anyway, then there is no point
69
63
in implementing vectorcall.
70
64
71
65
Classes can implement the vectorcall protocol by enabling the
72
- :const: `_Py_TPFLAGS_HAVE_VECTORCALL ` flag and setting
66
+ :const: `Py_TPFLAGS_HAVE_VECTORCALL ` flag and setting
73
67
:c:member: `~PyTypeObject.tp_vectorcall_offset ` to the offset inside the
74
68
object structure where a *vectorcallfunc * appears.
75
69
This is a pointer to a function with the following signature:
@@ -97,7 +91,7 @@ This is a pointer to a function with the following signature:
97
91
argument 1 (not 0) in the allocated vector.
98
92
The callee must restore the value of ``args[-1] `` before returning.
99
93
100
- For :c:func: `_PyObject_VectorcallMethod `, this flag means instead that
94
+ For :c:func: `PyObject_VectorcallMethod `, this flag means instead that
101
95
``args[0] `` may be changed.
102
96
103
97
Whenever they can do so cheaply (without additional allocation), callers
@@ -107,7 +101,20 @@ This is a pointer to a function with the following signature:
107
101
108
102
To call an object that implements vectorcall, use a :ref: `call API <capi-call >`
109
103
function as with any other callable.
110
- :c:func: `_PyObject_Vectorcall ` will usually be most efficient.
104
+ :c:func: `PyObject_Vectorcall ` will usually be most efficient.
105
+
106
+
107
+ .. note ::
108
+
109
+ In CPython 3.8, the vectorcall API and related functions were available
110
+ provisionally under names with a leading underscore:
111
+ ``_PyObject_Vectorcall ``, ``_Py_TPFLAGS_HAVE_VECTORCALL ``,
112
+ ``_PyObject_VectorcallMethod ``, ``_PyVectorcall_Function ``,
113
+ ``_PyObject_CallOneArg ``, ``_PyObject_CallMethodNoArgs ``,
114
+ ``_PyObject_CallMethodOneArg ``.
115
+ Additionally, ``PyObject_VectorcallDict `` was available as
116
+ ``_PyObject_FastCallDict ``.
117
+ The old names are still defined as aliases of the new, non-underscored names.
111
118
112
119
113
120
Recursion Control
@@ -137,17 +144,21 @@ Vectorcall Support API
137
144
However, the function ``PyVectorcall_NARGS`` should be used to allow
138
145
for future extensions.
139
146
147
+ This function is not part of the `limited API <stable>`_.
148
+
140
149
.. versionadded:: 3.8
141
150
142
- .. c:function:: vectorcallfunc _PyVectorcall_Function (PyObject *op)
151
+ .. c:function:: vectorcallfunc PyVectorcall_Function (PyObject *op)
143
152
144
153
If *op * does not support the vectorcall protocol (either because the type
145
154
does not or because the specific instance does not), return *NULL*.
146
155
Otherwise, return the vectorcall function pointer stored in *op*.
147
156
This function never raises an exception.
148
157
149
158
This is mostly useful to check whether or not *op* supports vectorcall,
150
- which can be done by checking ``_PyVectorcall_Function(op) != NULL``.
159
+ which can be done by checking ``PyVectorcall_Function(op) != NULL``.
160
+
161
+ This function is not part of the `limited API <stable>`_.
151
162
152
163
.. versionadded:: 3.8
153
164
@@ -158,9 +169,11 @@ Vectorcall Support API
158
169
159
170
This is a specialized function, intended to be put in the
160
171
:c:member: `~PyTypeObject.tp_call ` slot or be used in an implementation of ``tp_call ``.
161
- It does not check the :const: `_Py_TPFLAGS_HAVE_VECTORCALL ` flag
172
+ It does not check the :const: `Py_TPFLAGS_HAVE_VECTORCALL ` flag
162
173
and it does not fall back to ``tp_call ``.
163
174
175
+ This function is not part of the `limited API <stable >`_.
176
+
164
177
.. versionadded :: 3.8
165
178
166
179
@@ -185,7 +198,7 @@ please see individual documentation for details.
185
198
+------------------------------------------+------------------+--------------------+---------------+
<
10000
tr class="diff-line-row">186
199
| :c:func: `PyObject_CallNoArgs ` | ``PyObject * `` | --- | --- |
187
200
+------------------------------------------+------------------+--------------------+---------------+
188
- | :c:func: `_PyObject_CallOneArg ` | ``PyObject * `` | 1 object | --- |
201
+ | :c:func: `PyObject_CallOneArg ` | ``PyObject * `` | 1 object | --- |
189
202
+------------------------------------------+------------------+--------------------+---------------+
190
203
| :c:func: `PyObject_CallObject ` | ``PyObject * `` | tuple/``NULL `` | --- |
191
204
+------------------------------------------+------------------+--------------------+---------------+
@@ -197,15 +210,15 @@ please see individual documentation for details.
197
210
+------------------------------------------+------------------+--------------------+---------------+
198
211
| :c:func: `PyObject_CallMethodObjArgs ` | obj + name | variadic | --- |
199
212
+------------------------------------------+------------------+--------------------+---------------+
200
- | :c:func: `_PyObject_CallMethodNoArgs ` | obj + name | --- | --- |
213
+ | :c:func: `PyObject_CallMethodNoArgs ` | obj + name | --- | --- |
201
214
+------------------------------------------+------------------+--------------------+---------------+
202
- | :c:func: `_PyObject_CallMethodOneArg ` | obj + name | 1 object | --- |
215
+ | :c:func: `PyObject_CallMethodOneArg ` | obj + name | 1 object | --- |
203
216
+------------------------------------------+------------------+--------------------+---------------+
204
- | :c:func: `_PyObject_Vectorcall ` | ``PyObject * `` | vectorcall | vectorcall |
217
+ | :c:func: `PyObject_Vectorcall ` | ``PyObject * `` | vectorcall | vectorcall |
205
218
+------------------------------------------+------------------+--------------------+---------------+
206
- | :c:func: `_PyObject_FastCallDict ` | ``PyObject * `` | vectorcall | dict/``NULL `` |
219
+ | :c:func: `PyObject_VectorcallDict ` | ``PyObject * `` | vectorcall | dict/``NULL `` |
207
220
+------------------------------------------+------------------+--------------------+---------------+
208
- | :c:func: `_PyObject_VectorcallMethod ` | arg + name | vectorcall | vectorcall |
221
+ | :c:func: `PyObject_VectorcallMethod ` | arg + name | vectorcall | vectorcall |
209
222
+------------------------------------------+------------------+--------------------+---------------+
210
223
211
224
@@ -235,14 +248,16 @@ please see individual documentation for details.
235
248
.. versionadded :: 3.9
236
249
237
250
238
- .. c :function :: PyObject* _PyObject_CallOneArg (PyObject *callable, PyObject *arg)
251
+ .. c :function :: PyObject* PyObject_CallOneArg (PyObject *callable, PyObject *arg)
239
252
240
253
Call a callable Python object *callable * with exactly 1 positional argument
241
254
*arg * and no keyword arguments.
242
255
243
256
Return the result of the call on success, or raise an exception and return
244
257
*NULL * on failure.
245
258
259
+ This function is not part of the `limited API <stable >`_.
83CB
code>
260
+
246
261
.. versionadded :: 3.9
247
262
248
263
@@ -320,18 +335,20 @@ please see individual documentation for details.
320
335
*NULL * on failure.
321
336
322
337
323
- .. c :function :: PyObject* _PyObject_CallMethodNoArgs (PyObject *obj, PyObject *name)
338
+ .. c :function :: PyObject* PyObject_CallMethodNoArgs (PyObject *obj, PyObject *name)
324
339
325
340
Call a method of the Python object *obj * without arguments,
326
341
where the name of the method is given as a Python string object in *name *.
327
342
328
343
Return the result of the call on success, or raise an exception and return
329
344
*NULL * on failure.
330
345
346
+ This function is not part of the `limited API <stable >`_.
347
+
331
348
.. versionadded :: 3.9
332
349
333
350
334
- .. c :function :: PyObject* _PyObject_CallMethodOneArg (PyObject *obj, PyObject *name, PyObject *arg)
351
+ .. c :function :: PyObject* PyObject_CallMethodOneArg (PyObject *obj, PyObject *name, PyObject *arg)
335
352
336
353
Call a method of the Python object *obj * with a single positional argument
337
354
*arg *, where the name of the method is given as a Python string object in
@@ -340,10 +357,12 @@ please see individual documentation for details.
340
357
Return the result of the call on success, or raise an exception and return
341
358
*NULL * on failure.
342
359
360
+ This function is not part of the `limited API <stable >`_.
361
+
343
362
.. versionadded :: 3.9
344
363
345
364
346
- .. c :function :: PyObject* _PyObject_Vectorcall (PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
365
+ .. c :function :: PyObject* PyObject_Vectorcall (PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
347
366
348
367
Call a callable Python object *callable *.
349
368
The arguments are the same as for :c:type: `vectorcallfunc `.
@@ -353,15 +372,11 @@ please see individual documentation for details.
353
372
Return the result of the call on success, or raise an exception and return
354
373
*NULL * on failure.
355
374
356
- .. note ::
357
-
358
- This function is provisional and expected to become public in Python 3.9,
359
- with a different name and, possibly, changed semantics.
360
- If you use the function, plan for updating your code for Python 3.9.
375
+ This function is not part of the `limited API <stable >`_.
361
376
362
- .. versionadded :: 3.8
377
+ .. versionadded :: 3.9
363
378
364
- .. c :function :: PyObject* _PyObject_FastCallDict (PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
379
+ .. c :function :: PyObject* PyObject_VectorcallDict (PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
365
380
366
381
Call *callable * with positional arguments passed exactly as in the vectorcall _ protocol,
367
382
but with keyword arguments passed as a dictionary *kwdict *.
@@ -373,15 +388,11 @@ please see individual documentation for details.
373
388
already has a dictionary ready to use for the keyword arguments,
374
389
but not a tuple for the positional arguments.
375
390
376
- .. note ::
391
+ This function is not part of the ` limited API < stable >`_.
377
392
378
- This function is provisional and expected to become public in Python 3.9,
379
- with a different name and, possibly, changed semantics.
380
- If you use the function, plan for updating your code for Python 3.9.
381
-
382
- .. versionadded :: 3.8
393
+ .. versionadded :: 3.9
383
394
384
- .. c :function :: PyObject* _PyObject_VectorcallMethod (PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames)
395
+ .. c :function :: PyObject* PyObject_VectorcallMethod (PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames)
385
396
386
397
Call a method using the vectorcall calling convention. The name of the method
387
398
is given as a Python string *name *. The object whose method is called is
@@ -390,7 +401,7 @@ please see individual documentation for details.
390
401
*nargsf * is the number of positional arguments including *args[0] *,
391
402
plus :const: `PY_VECTORCALL_ARGUMENTS_OFFSET ` if the value of ``args[0] `` may
392
403
temporarily be changed. Keyword arguments can be passed just like in
393
- :c:func: `_PyObject_Vectorcall `.
404
+ :c:func: `PyObject_Vectorcall `.
394
405
395
406
If the object has the :const: `Py_TPFLAGS_METHOD_DESCRIPTOR ` feature,
396
407
this will call the unbound method object with the full
@@ -399,6 +410,8 @@ please see individual documentation for details.
399
410
Return the result of the call on success, or raise an exception and return
400
411
*NULL * on failure.
401
412
413
+ This function is not part of the `limited API <stable >`_.
414
+
402
415
.. versionadded :: 3.9
403
416
404
417
0 commit comments