Wrapping C code and running it in Python
2019-06-05, 13:00–16:30, Room 2

Python is known for its ability to interoperate with other languages. We will learn how to call C from Python using CFFI, Ctypes, Cython, and others


The workshop is based on the jupyter notebook avaiable here. You will want to make sure you have an appropriate python3 environment ready, including cppyy which can be installed via pip.

Starting from a simple pure-python program to produce a Mandlebrot fractal image, we will learn how to:

  • Benchmark and profile python performance

  • Write the time-critical code in C

  • Call the c code from Python using CFFI, Ctypes, Cython, and if time allows CPPYY and PyBind11.

  • Compare and contrast the methods: ease of use, maintainability, speed and popularity

At the end we will discuss other solutions for making the pure-python version fast.