Skip to content

Commit 9ca3f08

Browse files
committed
cython chapter: add list of other similar tools
1 parent c4e8904 commit 9ca3f08

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

content/cython.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ float, double float
261261
char \* str/bytes
262262
============= ===============
263263

264+
264265
Using Numpy arrays with Cython
265266
------------------------------
266267

@@ -388,10 +389,21 @@ Cython (see also `Cython docs <https://cython.readthedocs.io/en/latest/src/quick
388389
- Only Cythonize the modules/functions for which performance is *really*
389390
needed. Profiling tools help at identifying such bottlenecks.
390391
- Static type declarations work the best for fundamental data types (integers,
391-
floats, strings) and for contiguous arrays. Operations on lists and
392-
dictionaries do not usually benefit much from Cython.
392+
floats, strings) and for contiguous arrays. Operations on heterogeneous lists
393+
and dictionaries do not usually benefit much from Cython.
394+
395+
396+
Alternatives to Cython
397+
----------------------
398+
399+
There exists a plethora of other tools and libraries for extending Python with
400+
compiled C code. If you already have a working C/C++ codebase and would like
401+
to use it from Python, consider using one of the following:
402+
403+
- `ctypes <https://docs.python.org/3/library/ctypes.html>`__: part of Python standard library.
404+
- `CFFI <https://cffi.readthedocs.io/en/stable/index.html>`__: somewhat similar to `ctypes` but with more features and probably better for large projects.
405+
- `pybind11 <https://pybind11.readthedocs.io/en/stable/index.html>`__: very robust and modern way of creating extension modules. C++ only.
393406

394-
TODO: when to use other C extension stuff
395407

396408
Further reading
397409
---------------
@@ -400,10 +412,6 @@ Further reading
400412
are a newer and more general way of interfacing with Numpy arrays and other buffer-like objects.
401413
- `Calling C functions from Cython <https://cython.readthedocs.io/en/latest/src/tutorial/external.html>`__
402414

403-
Summary
404-
-------
405-
406-
- TODO
407415

408416
Acknowledgements
409417
----------------

0 commit comments

Comments
 (0)