EuroPython 2018

Fast native code with Cython

Speaker(s) Stefan Behnel

Cython is not only an excellent and widely used tool to speed up computational Python code, it’s also a very comfortable way to talk to native code and libraries. The Cython compiler translates Python code to C or C++ code, and supports static type annotations to allow direct use of C/C++ data types and functions. The tight integration of all three languages makes it possible to freely mix Python features like generators and comprehensions with C/C++ features like native data types, pointer arithmetic or manually tuned memory management in the same code.

This tutorial by a core developer introduces the Cython compiler by interactive code examples, and shows how you can make it generate fast binary modules that talk to native libraries, as easily as Python itself.

Attendees should make sure they have a C compiler installed and configured to build binary Packages for CPython. We will use CPython 3.6/7, although all examples can also be followed with CPython 2.7. If you’re not on Linux, I recomment using a conda environment with gcc.

Update 2018-07-23: Please set up a virtualenv or conda-env with the following tools:

  • jupyter
  • numpy
  • Cython==0.28.4
  • optionally (relatively large download): matplotlib

in on Tuesday 24 July at 13:45 See schedule
in on Tuesday 24 July at 15:15 See schedule

Do you have some questions on this talk?

New comment