Rust comes to CPython: zlib will be the first module

Translated by a model; the original is in Russian.

· Linux and open source
At the Python Language Summit 2026 the Rust for CPython team laid out a roadmap for gradually bringing Rust into the interpreter — starting with an optional implementation of the zlib module in Python 3.16.

cover.svg

At the 2026 Python Language Summit, David Hewitt — acting as an "ambassador" for the Rust for CPython project — asked core developers what they want from Rust and proposed timelines, phases, and success criteria. The idea was first floated cautiously at PyCon US a year ago; as Hewitt put it, "no one said don't do this."

The project is led by core developers Kirill Podoprigora and Emma Smith, authors of the draft PEP. Around it has formed a community of roughly 60 people in a Discord channel, including a few CPython core developers and a "delegation from the Rust project" with experience integrating Rust into Android and the Linux kernel.

Why Rust

Hewitt noted that the number of issues labeled "type-crash" has been steadily rising — perhaps because of big bets like the new parser, the JIT, and free-threading. Rust can eliminate whole classes of such bugs. He described Android's experience as "move fast and fix things": fewer revisions per patch of the same size. He was candid, though, that Rust guarantees no freedom from logic errors, so the team plans to lean on property-based testing and fuzzing.

Challenges remain. Rust's platform support has widened over the past year, but CPython officially supports 20 architectures. Rust knowledge is "not universal" among core developers, so the approach is incremental: a million lines of C can't be ported all at once.

zlib goes first

The first module to be ported is zlib: small in scope, but with a visible payoff. The implementation builds on zlib-rs (used by Firefox, uv, and Cargo) and is faster than zlib on many platforms. Since zlib is heavily used in Python packaging, "almost every pip install in 3.16 will be sped up."

Under the plan, Rust is optional in Python 3.16 (October 2027), with the C code kept as a fallback. Python 3.17 (2028) would add io, json, xml, memoryview, and the parser. Rust wouldn't become required to build CPython before Python 3.18 (2029), when a public Rust API would also appear.

Debate

Thomas Wouters urged the team not to make "compromises for the dinosaurs" and to design the API from first principles. Larry Hastings asked why this wasn't a rewrite, and admitted he wasn't thrilled about learning Rust; Hewitt assured him "CPython should not be written in Rust for the sake of Rust" and that the project would stay dual-language for a long time — though it would be disingenuous to promise Rust stays optional forever.

Pablo Galindo flagged a potential "showstopper": pulling dependencies from Cargo, given that CPython carefully curates and vendors its dependencies. Hewitt replied that external dependencies would be kept to a minimum, zlib-rs being the only one, and that sources would be vendored separately so building CPython wouldn't require Cargo.


Source: Lobsters

Comments

Sign in, to comment.

  • No comments yet.