Contribute Media
A thank you to everyone who makes this possible: Read More

Call C code quickly and compatibly with CFFI

Translations: en

Description

Have you ever wanted to speed up a slow part of your Python program by rewriting part of it in C? Maybe you needed to use a C/C++ library, but couldn't find a Python binding? This talk will get you started with CFFI, a modern approach to calling into C code from Python. CFFI (FFI stands for 'foreign function interface') produces code that works with both CPython and PyPy, and across Python 2 and 3. It doesn't require learning a custom 'wrapping' language, and can have less runtime overhead than ctypes.

In my talk, I'll walk through the process of exposing a small C-based data structure in Python, and then packaging it up with setuptools. You don't need to be an expert C programmer to get great results!

Details

Improve this page