Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-133678: Add a banner to C API doc to recommend 3rd party tools #133679

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update
  • Loading branch information
vstinner committed May 9, 2025
commit abfa1884078322a0eca07b07638ca5150cc14387
12 changes: 9 additions & 3 deletions 12 Doc/c-api/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,15 @@ approaches to creating C and C++ extensions for Python:
* `PyO3 <https://pyo3.rs/>`_ (Rust)
* `SWIG <https://www.swig.org>`_

It is recommended to use these abstractions, rather than using directly the
Python C API. These abstractions are built on top of the C API and handle API
differences between the different Python versions.
Using tools such as these can help avoid writing code that is tightly bound to
a particular version of CPython, avoid reference counting errors, and focus
more on your own code than on using the CPython API. In general, new versions
of Python can be supported by updating the tool, and your code will often use
newer and more efficient APIs automatically. Some tools also support compiling
for other implementations of Python from a single set of sources.

Directly coding against the CPython C API should, in most cases, be your last
resort rather than the first.

These projects are not supported by the same people who maintain Python, and
issues need to be raised with the projects directly. Remember to check that the
Expand Down
2 changes: 1 addition & 1 deletion 2 Doc/tools/extensions/c_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class CAPIToolsBanner(SphinxDirective):

text = sphinx_gettext(
"It is recommended to use "
":ref:`C API abstractions <c-api-tools>`, "
":ref:`third party tools <c-api-tools>`, "
"rather than using the Python C API directly."
)

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.