Skip to content

Commit 5644df2

Browse files
Update development-tools/clinic.rst
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 1322930 commit 5644df2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

development-tools/clinic.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,23 +1495,33 @@ You can still use a self converter, a return converter, and specify
14951495
a *type* argument to the object converter for :c:macro:`METH_O`.
14961496

14971497

1498-
How to convert var-positional parameter functions
1499-
-------------------------------------------------
1498+
How to convert ``*args`` parameters (starargs / var-positional)
1499+
---------------------------------------------------------------
1500+
1501+
There are two converters suitable for ``*args``: *array* and *tuple*.
15001502

1501-
To convert a var-positional parameter function, prepend the parameter name
1502-
with ``*`` and use the the ``array`` converter.
1503+
Using the *array* converter will provide the implementation function with
1504+
a C array *args* of type of :c:type:`PyObject * <PyObject>` and the number
1505+
of items in the array as :c:type:`Py_ssize_t` *args_length*.
15031506
For example::
15041507

15051508
/*[clinic input]
15061509
var_positional_sample
15071510

1508-
foo: int
1511+
spam: int
15091512
*args: array
15101513
[clinic start generated code]*/
15111514

1512-
The implementation function will receive var-positional arguments as C array
1513-
*args* of :c:type:`PyObject * <PyObject>`. Alternatively, you could use
1514-
``tuple`` converter to pass a regular :c:type:`PyTupleObject` as argument.
1515+
Using the *tuple* converter will provide the implementation function with
1516+
a standard :c:type:`PyTupleObject`.
1517+
For example::
1518+
1519+
/*[clinic input]
1520+
var_positional_sample
1521+
1522+
spam: int
1523+
*args: tuple
1524+
[clinic start generated code]*/
15151525

15161526
.. versionadded:: 3.11
15171527

0 commit comments

Comments
 (0)