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.

Please be sure you have a computer with anaconda python installed and a compiler (for windows users - Visual Studio 2019 is recommended. Others should have a functioniong gcc or clang). You should also download the git repo and be sure you can run the first few cells that involve compilation (before the ctypes discussion). Also please be sure to preinstall cppyy.

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