Rusty Python: A Case Study
04-18, 11:05–11:35 (Europe/Berlin), Kuppelsaal

Python is a very expressive and powerful language, but it is not always the fastest option for performance-critical parts of an application. Rust, on the other hand, is known for its lightning-fast runtime and low-level control, making it an attractive option for speeding up performance-sensitive portions of Python programs.

In this talk, we will present a case study of using Rust to speed up a critical component of a Python application. We will cover the following topics:

  • An overview of Rust and its benefits for Python developers
  • Profiling and identifying performance bottlenecks in Python application
  • Implementing a solution in Rust and integrating it with the Python application using PyO3
  • Measuring the performance improvements and comparing them to other optimization techniques

Attendees will learn about the potential for using Rust to boost the performance of their Python programs and how to go about doing so in their own projects.


In the past, C and C++ were the go-to languages for optimizing Python code while still maintaining a high-level interface. This approach was used by well-known numerical libraries such as Numpy and Pandas. However, with the increasing popularity of Rust and the emergence of PyO3, this is no longer the only solution available. Rust's impressive performance and expressive syntax, combined with its comprehensive library ecosystem, make it a viable alternative for optimizing performance-sensitive parts of Python applications. Additionally, Rust's mature support for asynchronous programming gives it an advantage over C foreign function interfaces when interacting with Python coroutines. Some library maintainers are even considering using Rust for their projects, such as Pydantic, which is implementing version 2 in Rust and achieving similar speed improvements to those obtained using C.


In minutes
* 0-2: Welcome, explanation of title
* 2-7: What is Rust and how is it different to other "bare metal" languages
* 7-10: Introducing the case study, running the code, getting feel for performance
* 10-15: Code profiling, finding of bottle neck
* 15-17: Introducing PyO3
* 17-22: Walking through the Rust code that optimizes the bottle neck
* 22-25: Running the code live, showing the speedup
* 25-28: Mention extensions provided by PyO3, caveats and what code might not be a good goal to optimize. Mention tradeoffs to other foreign function interfaces.
* 28-30: Buffer / Q&A

Expected audience expertise: Domain


Expected audience expertise: Python


Abstract as a tweet

Talk on optimizing Python performance with Rust and PyO3, including case study, code profiling, and live demonstration of speedup. Discussion on PyO3 features and tradeoffs with other FFI options.

I have had a diverse career, starting out in academia as a mathematician and transitioning to work in startups as an engineer in the second half of my career. I thrive on wearing many hats and having a strong impact on the direction of the company. For the past two years, I have been working at Taktile, a series A startup with around 50 employees, where I serve as the lead technical engineer. My passion for programming has led me to work with a wide range of languages, including Haskell, Rust, C++, Typescript, and Python.