Skip to content

Commit 9823377

Browse files
committed
emphasize that cffi is better than extension modules for portability
1 parent a675c8b commit 9823377

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Doc/extending/extending.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ source file by including the header ``"Python.h"``.
2020
The compilation of an extension module depends on its intended use as well as on
2121
your system setup; details are given in later chapters.
2222

23-
Do note that if your use case is calling C library functions or system calls,
24-
you should consider using the :mod:`ctypes` module rather than writing custom
25-
C code. Not only does :mod:`ctypes` let you write Python code to interface
26-
with C code, but it is more portable between implementations of Python than
27-
writing and compiling an extension module which typically ties you to CPython.
23+
.. note::
2824

25+
The C extension interface is specific to CPython, and extension modules do
26+
not work on other Python implementations. In many cases, it is possible to
27+
avoid writing C extensions and preserve portability to other implementations.
28+
For example, if your use case is calling C library functions or system calls,
29+
you should consider using the :mod:`ctypes` module or the `cffi
30+
<http://cffi.readthedocs.org>`_ library rather than writing custom C code.
31+
These modules let you write Python code to interface with C code and are more
32+
portable between implementations of Python than writing and compiling a C
33+
extension module.
2934

3035

3136
.. _extending-simpleexample:

0 commit comments

Comments
 (0)