Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133678: Document C API third party tools#134526
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
vstinner wants to merge3 commits intopython:mainChoose a base branch fromvstinner:capi_tools
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+46 −35
Open
Changes from1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
gh-133678: Document C API third party tools
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit45b3c5f3fc9c13cb237c9e20a1649cb6f4bccb4c
There are no files selected for viewing
41 changes: 41 additions & 0 deletionsDoc/c-api/intro.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 |
---|---|---|
@@ -838,3 +838,44 @@ after every statement run by the interpreter.) | ||
Please refer to :file:`Misc/SpecialBuilds.txt` in the Python source distribution | ||
for more detailed information. | ||
.. _c-api-tools: | ||
Recommended third party tools | ||
============================= | ||
The following third party tools offer both simpler and more sophisticated | ||
approaches to creating C and C++ extensions for Python: | ||
* `Cython <https://cython.org/>`_ | ||
* `cffi <https://cffi.readthedocs.io>`_ | ||
* `HPy <https://hpyproject.org/>`_ | ||
* `nanobind <https://github.com/wjakob/nanobind>`_ (C++) | ||
* `Numba <https://numba.pydata.org/>`_ | ||
* `pybind11 <https://pybind11.readthedocs.io/>`_ (C++) | ||
* `PyO3 <https://pyo3.rs/>`_ (Rust) | ||
* `SWIG <https://www.swig.org>`_ | ||
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. | ||
vstinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
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 | ||
project is still maintained and supported, as the list above may become | ||
outdated. | ||
.. seealso:: | ||
`Python Packaging User Guide: Binary Extensions <https://packaging.python.org/guides/packaging-binary-extensions/>`_ | ||
The Python Packaging User Guide not only covers several available | ||
tools that simplify the creation of binary extensions, but also | ||
discusses the various reasons why creating an extension module may be | ||
desirable in the first place. |
16 changes: 3 additions & 13 deletionsDoc/extending/index.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 |
---|---|---|
@@ -26,19 +26,9 @@ Recommended third party tools | ||
============================= | ||
This guide only covers the basic tools for creating extensions provided | ||
as part of this version of CPython. :ref:`Recommended third party tools | ||
<c-api-tools>` offer both simpler and more sophisticated approaches to creating | ||
vstinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
C and C++ extensions for Python. | ||
Creating extensions without third party tools | ||
21 changes: 3 additions & 18 deletionsDoc/faq/extending.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
6 changes: 2 additions & 4 deletionsDoc/howto/cporting.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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.