Skip to content

Commit 2e3b673

Browse files
vstinnerAlexWaygooderlend-aasland
committed
python/cpython#108494: Argument Clinic: Document how to generate code that uses the limited C API (python/cpython#108584)
Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 3ab432c commit 2e3b673

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

development-tools/clinic.rst

+22-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ process a single source file, like this:
152152
The CLI supports the following options:
153153

154154
.. program:: ./Tools/clinic/clinic.py [-h] [-f] [-o OUTPUT] [-v] \
155-
[--converters] [--make] [--srcdir SRCDIR] [FILE ...]
155+
[--converters] [--make] [--srcdir SRCDIR] [--limited] [FILE ...]
156156

157157
.. option:: -h, --help
158158

@@ -187,6 +187,11 @@ The CLI supports the following options:
187187
A file to exclude in :option:`--make` mode.
188188
This option can be given multiple times.
189189

190+
.. option:: --limited
191+
192+
Use the :ref:`Limited API <limited-c-api>` to parse arguments in the generated C code.
193+
See :ref:`clinic-howto-limited-capi`.
194+
190195
.. option:: FILE ...
191196

192197
The list of files to process.
@@ -1899,6 +1904,22 @@ blocks embedded in Python files look slightly different. They look like this:
18991904
#/*[python checksum:...]*/
19001905
19011906
1907+
.. _clinic-howto-limited-capi:
1908+
1909+
How to use the Limited C API
1910+
----------------------------
1911+
1912+
If Argument Clinic :term:`input` is located within a C source file
1913+
that contains ``#define Py_LIMITED_API``, Argument Clinic will generate C code
1914+
that uses the :ref:`Limited API <limited-c-api>` to parse arguments. The
1915+
advantage of this is that the generated code will not use private functions.
1916+
However, this *can* result in Argument Clinic generating less efficient code
1917+
in some cases. The extent of the performance penalty will depend
1918+
on the parameters (types, number, etc.).
1919+
1920+
.. versionadded:: 3.13
1921+
1922+
19021923
.. _clinic-howto-override-signature:
19031924

19041925
How to override the generated signature

0 commit comments

Comments
 (0)