Hands-on: Adding static typing to heat equation

In this exercise, we create a Cython extension for the heat equation solver and add static typing.

The code for this exercise is located under cython/heat-equation.

Creating a Cython extension

Based on the profile in the performance measurement exercise write a setup.py for creating a Cython module for the most time consuming part of the heat equation solver. If you did not finish the profiling exercise, you can look at example profile here.

Type declarations

Insert static type declarations to proper locations. Investigate the effect on performance. You can use applications own timers and/or timeit. Annotated HTML-report with cython –a … can be useful when tuning performance.

Please comment how much speedup you could get!

Share this article:

This article is from the free online course:

Python in High Performance Computing

Partnership for Advanced Computing in Europe (PRACE)