Skip main navigation

Hands-on: utilizing C code

In this exercise you can practice utilizing C code from Python.
© CSC - IT Center for Science

Using C code in the heat equation

The code for this exercise is located under interface/c.

~/hpc-python$ cd interface/c

Using cffi

The files evolve.h and evolve.c contain a pure C implementation of the
single time step in heat equation. The C implemention can be built into a
shared library with the provided Makefile by executing make
command. Use cffi for utilizing the library function instead of the Python
function in heat.py. Compare the performance to Cython implementation

© 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