@@ -127,15 +127,15 @@ complete listing.
127127 item defined in the module file. Example::
128128
129129 static struct PyModuleDef spam_module = {
130- PyModuleDef_HEAD_INIT,
130+ .m_base = PyModuleDef_HEAD_INIT,
131131 .m_name = "spam",
132132 ...
133133 };
134134
135135 PyMODINIT_FUNC
136136 PyInit_spam(void)
137137 {
138- return PyModule_Create (&spam_module);
138+ return PyModuleDef_Init (&spam_module);
139139 }
140140
141141
@@ -838,3 +838,41 @@ after every statement run by the interpreter.)
838838
839839Please refer to :file: `Misc/SpecialBuilds.txt ` in the Python source distribution
840840for more detailed information.
841+
842+
843+ .. _c-api-tools :
844+
845+ Recommended third party tools
846+ =============================
847+
848+ The following third party tools offer both simpler and more sophisticated
849+ approaches to creating C, C++ and Rust extensions for Python:
850+
851+ * `Cython <https://cython.org/ >`_
852+ * `cffi <https://cffi.readthedocs.io >`_
853+ * `HPy <https://hpyproject.org/ >`_
854+ * `nanobind <https://github.com/wjakob/nanobind >`_ (C++)
855+ * `Numba <https://numba.pydata.org/ >`_
856+ * `pybind11 <https://pybind11.readthedocs.io/ >`_ (C++)
857+ * `PyO3 <https://pyo3.rs/ >`_ (Rust)
858+ * `SWIG <https://www.swig.org >`_
859+
860+ Using tools such as these can help avoid writing code that is tightly bound to
861+ a particular version of CPython, avoid reference counting errors, and focus
862+ more on your own code than on using the CPython API. In general, new versions
863+ of Python can be supported by updating the tool, and your code will often use
864+ newer and more efficient APIs automatically. Some tools also support compiling
865+ for other implementations of Python from a single set of sources.
866+
867+ These projects are not supported by the same people who maintain Python, and
868+ issues need to be raised with the projects directly. Remember to check that the
869+ project is still maintained and supported, as the list above may become
870+ outdated.
871+
872+ .. seealso ::
873+
874+ `Python Packaging User Guide: Binary Extensions <https://packaging.python.org/guides/packaging-binary-extensions/ >`_
875+ The Python Packaging User Guide not only covers several available
876+ tools that simplify the creation of binary extensions, but also
877+ discusses the various reasons why creating an extension module may be
878+ desirable in the first place.
0 commit comments