Skip to content

Commit eff9a85

Browse files
authored
Merge pull request #651 from bsolomon1124/binary-ext-use-case-examples
Binary extension use cases: provide examples
2 parents 1306cef + 1057630 commit eff9a85

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

source/guides/packaging-binary-extensions.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,33 @@ Use cases
2525
The typical use cases for binary extensions break down into just three
2626
conventional categories:
2727

28-
* accelerator modules: these modules are completely self-contained, and
28+
* **accelerator modules**: these modules are completely self-contained, and
2929
are created solely to run faster than the equivalent pure Python code
3030
runs in CPython. Ideally, accelerator modules will always have a pure
3131
Python equivalent to use as a fallback if the accelerated version isn't
3232
available on a given system. The CPython standard library makes extensive
3333
use of accelerator modules.
34-
35-
* wrapper modules: these modules are created to expose existing C interfaces
34+
*Example*: When importing ``datetime``, Python falls back to the
35+
`datetime.py <https://github.com/python/cpython/blob/master/Lib/datetime.py>`_
36+
module if the C implementation (
37+
`_datetimemodule.c <https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c>`_)
38+
is not available.
39+
* **wrapper modules**: these modules are created to expose existing C interfaces
3640
to Python code. They may either expose the underlying C interface directly,
3741
or else expose a more "Pythonic" API that makes use of Python language
3842
features to make the API easier to use. The CPython standard library makes
3943
extensive use of wrapper modules.
40-
41-
* low level system access: these modules are created to access lower level
44+
*Example*: `functools.py <https://github.com/python/cpython/blob/master/Lib/functools.py>`_
45+
is a Python module wrapper for
46+
`_functoolsmodule.c <https://github.com/python/cpython/blob/master/Modules/_functoolsmodule.c>`_.
47+
* **low-level system access**: these modules are created to access lower level
4248
features of the CPython runtime, the operating system, or the underlying
4349
hardware. Through platform specific code, extension modules may achieve
4450
things that aren't possible in pure Python code. A number of CPython
4551
standard library modules are written in C in order to access interpreter
4652
internals that aren't exposed at the language level.
53+
*Example*: ``sys``, which comes from
54+
`sysmodule.c <https://github.com/python/cpython/blob/master/Python/sysmodule.c>`_.
4755

4856
One particularly notable feature of C extensions is that, when they don't
4957
need to call back into the interpreter runtime, they can release CPython's

0 commit comments

Comments
 (0)