FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Document how to use varargs in Argument Clinic by skirpichev · Pull Request #1629 · python/devguide · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
31 changes: 31 additions & 0 deletions development-tools/clinic.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,37 @@ You can still use a self converter, a return converter, and specify
a *type* argument to the object converter for :c:macro:`METH_O`.


How to convert ``*args`` parameters (starargs / var-positional)
---------------------------------------------------------------

There are two converters suitable for ``*args``: *array* and *tuple*.

Using the *array* converter will provide the implementation function with
a C array *args* of type of :c:type:`PyObject * <PyObject>` and the number
of items in the array as :c:type:`Py_ssize_t` *args_length*.
For example::

/*[clinic input]
var_positional_sample

spam: int
*args: array
[clinic start generated code]*/

Using the *tuple* converter will provide the implementation function with
a standard :c:type:`PyTupleObject`.
For example::

/*[clinic input]
var_positional_sample

spam: int
*args: tuple
[clinic start generated code]*/

.. versionadded:: 3.11


How to convert ``tp_new`` and ``tp_init`` functions
---------------------------------------------------

Expand Down

Back | FazBrowse Home | New Git URL