[Python-checkins] cpython (2.7): emphasize that cffi is better than extension modules for portability

benjamin.peterson python-checkins at python.org
Mon Jan 5 21:39:16 CET 2015


https://hg.python.org/cpython/rev/518f40815684
changeset:   94028:518f40815684
branch:      2.7
parent:      94017:e8342b3154d1
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Jan 05 14:38:46 2015 -0600
summary:
  emphasize that cffi is better than extension modules for portability

files:
  Doc/extending/extending.rst |  15 ++++++++++-----
  1 files changed, 10 insertions(+), 5 deletions(-)


diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst
--- a/Doc/extending/extending.rst
+++ b/Doc/extending/extending.rst
@@ -20,12 +20,17 @@
 The compilation of an extension module depends on its intended use as well as on
 your system setup; details are given in later chapters.
 
-Do note that if your use case is calling C library functions or system calls,
-you should consider using the :mod:`ctypes` module rather than writing custom
-C code. Not only does :mod:`ctypes` let you write Python code to interface
-with C code, but it is more portable between implementations of Python than
-writing and compiling an extension module which typically ties you to CPython.
+.. note::
 
+   The C extension interface is specific to CPython, and extension modules do
+   not work on other Python implementations.  In many cases, it is possible to
+   avoid writing C extensions and preserve portability to other implementations.
+   For example, if your use case is calling C library functions or system calls,
+   you should consider using the :mod:`ctypes` module or the `cffi
+   <http://cffi.readthedocs.org>`_ library rather than writing custom C code.
+   These modules let you write Python code to interface with C code and are more
+   portable between implementations of Python than writing and compiling a C
+   extension module.
 
 
 .. _extending-simpleexample:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list