Workshop

Rust-Python interoperability

Thursday, May 29

11:05 - 13:05
RoomPizza
LanguageEnglish
Audience levelIntermediate
Seats left34
    Elevator pitch

    Python shines for its flexibility and speed of iteration, but it doesn’t deliver amazing performance on its own. That’s where Rust comes in: you can harness the full power of the underlying hardware by rewriting hot modules as native extensions, without having to touch the rest of the application!

    Abstract

    Python has served you well: you spun up a prototype and iterated quickly, keeping up with the evolving requirements of a successful product. Nonetheless, as time goes on, cracks are starting to show up: an endpoint is slower than it needs to be, a data processing job that took seconds now takes almost an hour, and your infrastructure bill is growing too fast compared to the size of your user base. Engineers are starting to whisper: is it time for a rewrite? Should we pause feature development to rebuild everything on more solid foundations? That’s an option, but it’s expensive.

    There’s another path: rather than throwing away your entire Python codebase to start over, you analyse your application and isolate the performance-critical bits—the so-called “hot modules” where your application spends most of its time. You will rewrite those in Rust and package them as a Python native extension. This workshop will teach you how.

    We will cover the pyo3 crate, the subtleties of Python’s Global interpreter lock, and typical examples that may arise in your daily Rust-Python interoperability work. By the end of the session, you will be well-equipped to seamlessly replace your slow Python modules with easy-to-use and blazingly fast Rust modules.

    We assume you are familiar Python and you have basic Rust knowledge, but we don’t assume any prior interoperability knowledge. We will provide a brief explanation and references whenever we rely on advanced features in either language.

    The workshop will be extremely hands-on: no slides, just a series of exercises and a tutor to help you while you work through them, building your understanding of each concept through a dedicated puzzle (with tests to verify your solutions).

    TagsPerformance and scalability techniques, Scientific Python, Language and features
    Participant

    Luca Palmieri

    Luca Palmieri builds technology products for a living. His current focus is on backend development, software architecture and the Rust programming language. He currently works at MainMatter as a Principal Engineering Consultant. He partners with teams across the industry to make sure they succeed in adopting or scaling their Rust usage, where it makes sense to do so. He was formerly at AWS and TrueLayer. He has been part of the Rust community since 2018 and is best known as the author of “Zero to Production in Rust”, an introduction to using Rust for backend development. When he is not coding, you’ll find him baking cakes or rolling pasta sheets.