Skip main navigation

Hands-on: Adding static typing to heat equation

In this exercise, we introduce static typing into heat equation solver.
© CC-BY-NC-SA 4.0 by CSC - IT Center for Science

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!

© CC-BY-NC-SA 4.0 by CSC - IT Center for Science
This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now