Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-108494: Argument Clinic: Document how to generate code that uses the limited C API #108584

Merged
merged 6 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ process a single source file, like this:
The CLI supports the following options:

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

.. option:: -h, --help

Expand Down Expand Up @@ -193,6 +193,11 @@ The CLI supports the following options:
A file to exclude in :option:`--make` mode.
This option can be given multiple times.

.. option:: --limited

Use the :ref:`Limited API <limited-c-api>` to parse arguments in the generated C code.
See :ref:`How to use the Limited C API <clinic-howto-limited-capi>`.
vstinner marked this conversation as resolved.
Show resolved Hide resolved

.. option:: FILE ...

The list of files to process.
Expand Down Expand Up @@ -1905,6 +1910,22 @@ blocks embedded in Python files look slightly different. They look like this:
#/*[python checksum:...]*/


.. _clinic-howto-limited-capi:

How to use the Limited C API
vstinner marked this conversation as resolved.
Show resolved Hide resolved
----------------------------

If Argument Clinic :term:`input` is located within a C source file
that contains ``#define Py_LIMITED_API``, Argument Clinic will generate C code
that uses the :ref:`Limited API <limited-c-api>` to parse arguments. The
advantage of this is that the generated code will not use private functions.
However, this *can* result in Argument Clinic generating less efficient code
in some cases. The extent of the performance penalty will depend
on the parameters (types, number, etc.).

.. versionadded:: 3.13


.. _clinic-howto-override-signature:

How to override the generated signature
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
:ref:`Argument Clinic <howto-clinic>` now has a partial support of the
:ref:`Limited API <limited-c-api>`. Patch by Victor Stinner.
:ref:`Limited API <limited-c-api>`: see Argument Clinic :ref:`How to use the
Limited C API <clinic-howto-limited-capi>`. Patch by Victor Stinner.
vstinner marked this conversation as resolved.
Show resolved Hide resolved