Home >>> Courses >>> Special Topics >>> Cython

What customers say ...

Good course. Very fast progress without any prior Python knowledge.

Daniel Fuchs, GIGATRONIK Ingolstadt GmbH, about the German version of the course "Python for Programmers" more...

A useful and quite comprehensive introduction to Python.

Emil Simon, Researcher about the course "Python for Scientists and Engineers" more...

Very crisp and precise knowledge of the subject /content. Very good and highly recommended for all Python beginners.

Dicken George System Development Engineer, Soitec Solar GmbH about the course "Python for Programmers and Python for Scientists and Engineers" more...

Mike is an outstanding teacher ... I will look for his classes in the future.

Jennifer Trasti, Software/Systems Engineer, Sandia National Laboratories, Albuquerque, NM, USA more...

I can absolutely recommend this course to everybody who wants to become productive with Python very quickly. ...

Dr. med. Beat Meister, Bern, Switzerland more...

Cython in Depth

Dates for Open Courses

Location Date Course Language
Leipzig June 16 - 17, 2016 Cython in Depth English register

Course also available as in-house training. Please ask us at info@python-academy.de

Our course High-Performance Computing with Python also covers Cython, focussing on the integration with NumPy.

This course is given by a core developer of the Cython open-source project.

Target Audience

The course targets medium level to experienced Python programmers who want to break through the limits of Python performance. A basic understanding of the C language is helpful but not required.


The Python programming language has been used successfully in a large number of application domains. Even performance critical applications, such as scientific computation frameworks or text processing applications, have been realized using Python in order to benefit from short development cycles and highly maintainable code.

However, the interpreted language also has its weaknesses. Tight algorithms in numerical computations and character processing often suffer from the overhead of object operations in arithmetic expressions or memory copies in string slicing. In high performance applications, the optimizations that can be performed at the language level may not be sufficient.

This is where the Cython programming language shows its strength. Cython is a general purpose programming language that forms a best-of-both-worlds cross between the Python language and the ubiquitous datatypes of the C/C++ language. It comes with an optimising compiler that translates Python code into C code for Python extension modules, and tightly adapts the generated code to the available static type information.

Cython code can be written as high-level Python code and manually optimised in well selected hot-spots by statically declaring data types or calling directly into external code written in C, C++ or compatible languages. This makes the entire range from simple, expressive Python code down to highly optimized, low-level C code available for programming in a single language.

The objective of this course is to get to know the Cython language, and to learn how to use it to speed up Python code by orders of magnitude. You will also learn how to wrap external C libraries to efficiently and comfortably use them from Python.

Course Content

My first Cython extension

  • using pyximport to quickly (re-)build extension modules
  • using cython.inline() to compile code at runtime
  • building extension modules with distutils

Speeding up Python code with Cython

  • fast access to Python's builtin types
  • fast looping over Python iterables and C types
  • string processing
  • fast arithmetic
  • incrementally optimizing Cython code
  • multi-threading outside of the GIL (Global Interpreter Lock)

Interfacing with external C code

  • calling into external C libraries
  • building against C libraries
  • writing Python wrapper APIs
  • calling C functions across extension module boundaries

Use of Python's buffer interface from Cython code

  • directly accessing data buffers of other Python extensions
  • retrieving meta data about the buffer layout
  • setting up efficient memory views on external buffers

Implementing fast Cython loops over NumPy arrays

  • looping over NumPy exported buffers
  • implementing a simple image processing algorithm
  • using "fused types" (simple templating) to implement an algorithm once and run it efficiently on different C data types

Use of parallel loops to make use of multiple processing cores

  • building modules with OpenMP
  • processing data in parallel
  • speeding up an existing loop using OpenMP threads

Note: the part on parallel processing requires a C compiler that supports OpenMP, e.g. gcc starting with 4.2, preferably 4.4 or later. It should be readily available in recent installations of both Linux and MacOS-X. Note that recent versions of XCode use the "clang" compiler, which does not support OpenMP. On these systems, please install gcc separately and make sure it can be used from your CPython installation. Users of Microsoft Windows must install the C compiler that was used to build their Python installation, e.g. the VS2008 Express or MinGW for Python 2.7.

Case studies

The participants are encouraged to send in short code examples from their own experience that they would like to see running faster by using Cython. Based on general interest and practicality, one or two of these examples will be examined as a case study. These examples must be available to the teacher at least one week before the course, and must be short but complete executable examples, including sufficient input data for benchmarking. Please be aware that example code that requires a substantial amount of explanation or background knowledge about a specific application domain will not be accepted.

Course Duration

2 days


The participants can follow all steps directly on their computers. There are exercises at the end of each unit providing ample opportunity to apply the freshly learned knowledge.

Course Material

Every participant receives comprehensive printed materials that cover the whole course content as wells a CD with all source codes and used software.

The Python Academy is sponsor of Python Unconference 2015.

[PyUnconf 2015]

The Python Academy is sponsor of EuroSciPy 2015.

[EuroSciPy 2015]

The Python Academy is sponsor of EuroPython 2015.

[EuroPython 2015]

The Python Academy is sponsor of PyData Berlin 2015.

[PyData Berlin 2015]

The Python Academy is sponsor of PyCon Montréal 2015.

[PyCon Montréal 2015]

The Python Academy is sponsor of Python BarCamp Köln 2015.

[Python BarCamp 2015]“ border=

The Python Academy is sponsor of Chemnitzer Linux-Tage 2015.

Chemnitzer Linux-Tage 2015 - 21. und 22. März 2015

The Python Academy is sponsor of Django Girls Wroclaw 2015.

[Django Girls Wroclaw 2015]

The Python Academy is sponsor of PyCon Ireland 2014.

[PyCon Ireland 2014]

The Python Academy is sponsor of EuroSciPy 2014.

[EuroSciPy 2014]

The Python Academy is sponsor of PyData London 2014.

[PyData London 2014]

The Python Academy is sponsor of EuroPython 2014.

[EuroPython 2014]

The Python Academy is sponsor of PyCon 2014 Montréal.

[PyCon 2014 Montréal]

The Python Academy is sponsor of Python BarCamp Köln 2014.

[Python BarCamp 2014]

The Python Academy is sponsor of PyConDE 2013.

[PyCon DE 2013]

The Python Academy is sponsor of EuroPython 2013.

[EuroPython 2013]

The Python Academy is sponsor of PyCon US 2013.

[PyCon US 2013]

The Python Academy is sponsor of EuroSciPy 2013.

[EuroSciPy 2013]

The Python Academy is sponsor of PyConPL 2012.

[PyCon PL 2012]


The next open cousers
details ...

Python Academy sponsors EuroPython conference 2013
details ...

Python Academy sponsors EuroSciPy conference 2013
details ...

Python Academy sponsors Python BarCamp in Cologne
details ...

Next Meeting of Leipzig Python User Group, November 12, 2013
details ...

Introduction to Django, November 11 - 13, 2013
details ...

Professional Testing with Python, November 25 - 27, 2013
details ...

Advanced Django, January 13 - 15, 2014
details ...

Python Academy sponsors PyCon US conference 2013
details ...

Python Academy founder receives PSF Community Service Award
details ...