CFFI, Ctypes, Cython, Cppyy: how to run C code from Python
2019-09-03, 14:00–15:30, Track 3 (Oteiza)

Python is flexible, C and C++ are fast. How to use them together? There are many ways to call C code from Python, we will learn about the major ones, find out when you would prefer to use one over the other.

Using the Jupyter notebook and a compiler, we will start with a pure python implementation of a mandlebrot image. Then we will write the computationally heavy part of the code in C, and learn how to call it from Ctypes (part of the Python standard library), CFFI (a newer and better Ctypes alternative), Cython (a compiler from Python to C), and CPPYY (like Ctypes and CFFI, but for C++).

Along the way we will stop to reflect on the advantages and disadvantages of each technique in terms of speed of development, runtime overhead, maintainability, and readability.

The participants will come away with an understanding of the tools, their strengths and weaknesses, and how to use them.

Domains – Big Data, General-purpose Python, Image Processing, Scientific data flow and persistence, Vector and array manipulation Project Homepage / Git Domain Expertise – some Python Skill Level – professional Project Homepage / Git Abstract as a tweet – Ctypes, CFFI, Cython, CPPYY - how to call C/C++ from Python