Tuesday 10:30
in large room
Using Cython and C++ kernels to speed up Python libraries
Anatoly Volkov, David Cortes
The main goal of this tutorial is to give a broader audience an overview of how high-performance libraries in Python are developed. Attendees will work with ready-made code templates and fill in missing parts to learn by doing.
Session Outline
- (5 min) Motivation: Problems with performance in Python and what to do with them
- (10 min) Understanding Linear Regression & Normal Equations: A brief introduction to the mathematical background, deriving the formulas that would be used for training
- (10 min) Implementing a Python Baseline: Writing a reference implementation on Python
- (20 min) Optimizing with Cython: Implementing a fast Cython-based kernel
- (20 min) Example of pybind11 use: Example of pybind11 usage for integrating kernels implemented in C++
- (15 min) Performance Comparison: Benchmarking Python vs. Cython vs. C++ & pybind11 implementations
- (10 min) Q&A and Discussion
By the end of this session, attendees will:
- Understand how Python libraries achieve high performance using Cython and C++
- Learn how to write and integrate custom Cython or C++ kernels
- Know when to optimize Python code and when to rely on existing libraries
We also hope that this tutorial will inspire more people to contribute to open-source high-performance libraries.