How Python Harnesses Rust through PyO3
summary
Shows exact plumbing: Python import lands in the CPython call opcode which routes through PyObject_Vectorcall into a generated extern "C" trampoline that runs Rust code produced by PyO3+maturin build. Demonstrates argument layout (args array, nargs, kwtuple), conversion traits from PyObject to Rust types, and a real-case microbenchmark (the word-count example is ~2–4× faster). Explains safety work: a panic trap and deferred refcounts around the boundary, plus ecosystem scale (≈350 new Rust-backed packages/month and ~3 billion downloads/year), and real adopters like pydantic, polars, cryptography, and ruff.
AI-written summary · about
chapters (10)
- 0:00PyO3 and talk intro
- 1:04Python and Rust synergy
- 7:20PyO3 goals
- 10:28Bridging Python and Rust
- 15:34Rust in Python growth
- 17:59Rewriting Python in Rust
- 18:20Python module from Rust
- 27:13Tracing Python to Rust
- 34:11Rust-Python safety boundary
- 39:05Key takeaways
related talks
46mPython + Rust = ?
44mDo Pythons Rust? How we used PyO3 to build a Python Stream Processor w/ a Rust Heart
36mPumping up Python modules using Rust
35mUsing Rust to write Python modules
01h 07m🐍 Python meets the crab 🦀 - Friendship at first sight?
15mPyO3: Rust 💚 Python
31mPumping up Python modules using Rust
28m"Python ‹3 Rust"
