@@ -335,6 +335,83 @@ Object Protocol
335335 *NULL * on failure.
336336
337337
338+ .. c :function :: PyObject* _PyObject_Vectorcall (PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
339+
340+ Call a callable Python object *callable *, using
341+ :c:data: `vectorcall <PyTypeObject.tp_vectorcall_offset> ` if possible.
342+
343+ *args * is a C array with the positional arguments.
344+
345+ *nargsf * is the number of positional arguments plus optionally the flag
346+ :const: `PY_VECTORCALL_ARGUMENTS_OFFSET ` (see below).
347+ To get actual number of arguments, use
348+ :c:func:`PyVectorcall_NARGS(nargsf) <PyVectorcall_NARGS>`.
349+
350+ *kwnames* can be either NULL (no keyword arguments) or a tuple of keyword
351+ names. In the latter case, the values of the keyword arguments are stored
352+ in *args* after the positional arguments.
353+ The number of keyword arguments does not influence *nargsf*.
354+
355+ *kwnames* must contain only objects of type ``str`` (not a subclass),
356+ and all keys must be unique.
357+
358+ Return the result of the call on success, or *NULL* on failure.
359+
360+ This uses the vectorcall protocol if the callable supports it;
361+ otherwise, the arguments are converted to use
362+ :c:member: `~PyTypeObject.tp_call `.
363+
364+ .. note ::
365+
366+ This function is provisional and expected to become public in Python 3.9,
367+ with a different name and, possibly, changed semantics.
368+ If you use the function, plan for updating your code for Python 3.9.
369+
370+ .. versionadded :: 3.8
371+
372+ .. c :var :: PY_VECTORCALL_ARGUMENTS_OFFSET
373+
374+ If set in a vectorcall *nargsf * argument, the callee is allowed to
375+ temporarily change ``args[-1] ``. In other words, *args * points to
376+ argument 1 (not 0) in the allocated vector.
377+ The callee must restore the value of ``args[-1]`` before returning.
378+
379+ Whenever they can do so cheaply (without additional allocation), callers
380+ are encouraged to use :const :`PY_VECTORCALL_ARGUMENTS_OFFSET`.
381+ Doing so will allow callables such as bound methods to make their onward
382+ calls (which include a prepended *self * argument) cheaply.
383+
384+ .. versionadded:: 3.8
385+
386+ .. c:function:: Py_ssize_t PyVectorcall_NARGS(size_t nargsf)
387+
388+ Given a vectorcall *nargsf* argument, return the actual number of
389+ arguments.
390+ Currently equivalent to ``nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET``.
391+
392+ .. versionadded:: 3.8
393+
394+ .. c:function:: PyObject* _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict)
395+
396+ Same as :c:func: `_PyObject_Vectorcall ` except that the keyword arguments
397+ are passed as a dictionary in *kwdict *. This may be *NULL * if there
398+ are no keyword arguments.
399+
400+ For callables supporting :c:data: `vectorcall <PyTypeObject.tp_vectorcall_offset> `,
401+ the arguments are internally converted to the vectorcall convention.
402+ Therefore, this function adds some overhead compared to
403+ :c:func: `_PyObject_Vectorcall `.
404+ It should only be used if the caller already has a dictionary ready to use.
405+
406+ .. note ::
407+
408+ This function is provisional and expected to become public in Python 3.9,
409+ with a different name and, possibly, changed semantics.
410+ If you use the function, plan for updating your code for Python 3.9.
411+
412+ .. versionadded :: 3.8
413+
414+
338415.. c :function :: Py_hash_t PyObject_Hash (PyObject *o)
339416
340417 .. index :: builtin: hash
0 commit comments