Talks

Using Rust in Free-Threaded vs Regular Python 3.13

Friday, May 16th, 2025 11:45 a.m.–12:15 p.m. in Hall C

Presented by

David Hewitt

Experience Level:

Advance experience

Description

Python 3.13's new free-threaded build brings the possibility of true parallel execution into Python code for the first time.

This brings promise of significant performance opportunity, but not without cost. Parallel execution is notorious for being challenging due to the additional complexity. This implies bugs, and the risk is particularly high for the compiled code powering Python - including the CPython interpreter itself (it's written in C). The main risk comes from data races, which can cause unpredictable and potentially dangerous crashes.

The Rust programming language is designed to prevent data races by construction; if your code runs, it should be data race free (unless you misuse unsafe Rust).

We'll explore the way that Rust does this, both from the rules of the language, and by the data structures it offers to complement those rules. We'll showcase this with examples of Rust (PyO3) code designed for "regular" Python 3.13 and how it changes to become compatible with the free-threaded build.

This will lead onto ideas which we can carry across languages to influence how we write Python (and maybe C/C++) to be correct in a free-threaded world, before closing with some tantalizing examples of software architectures made possible by free-threaded Python.

No prior Rust knowledge necessary.

What you should hope to take away from this talk: - a basic understanding of how the free-threaded build of Python is different to the regular one, - an appreciation for the complexity of free-threading for compiled code, - how Rust helps you reason about this complexity, and - excitement for the future of free-threaded Python!

Search