Skip to content

Why Is Python Adopting Rust? The Rust for CPython Project Explained

I’ve been following the Rust for CPython project for a while now, and I think it’s one of the most significant developments in Python’s recent history. The project aims to introduce Rust code into CPython - Python’s reference implementation - to improve performance, memory safety, and maintainability. If you’re wondering why Python, a language known for its simplicity, would embrace Rust, you’re not alone. Let me break it down.

The Direct Answer

The Rust for CPython project is working toward a Python Enhancement Proposal (PEP) to make Rust an official part of Python 3.16, targeting a beta release in May 2027. This isn’t just an experiment anymore - they’ve successfully built CPython with Rust across all tested platforms in CI, and they’re having productive discussions with the Rust team about integration needs.

Why CPython Needs Rust

CPython is primarily written in C, which has served Python well for decades. But C comes with trade-offs: memory safety issues require careful manual management, and modern tooling lags behind what Rust offers. Rust provides memory safety without garbage collection, performance comparable to C, and modern developer tools.

Here’s how the architecture would look:

┌─────────────────────────────────────────────────────────────┐
│ Python User Code │
│ (Your Python Scripts) │
└─────────────────────┬───────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ CPython Interpreter │
├─────────────────────┬───────────────────────────────────────┤
│ │ │
│ C Components │ Rust Components │
│ (Existing Core) │ (New Memory-Safe Parts) │
│ │ │
│ - Object System │ - Specific Modules │
│ - Bytecode Exec │ - Memory-Intensive Operations │
│ - Built-in Types │ - Performance-Critical Code │
└─────────────────────┴───────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Hardware / OS Layer │
└─────────────────────────────────────────────────────────────┘

Current Progress

The team has made tangible progress:

  1. Build System Integration: Complete across all platforms tested in CI
  2. API Design Planning: The team is now designing the internal Rust API, tracked publicly on GitHub with the api-design label
  3. Rust Team Collaboration: Productive discussions about integration needs
  4. API Privacy: The internal Rust API will remain private until a future PEP stabilizes it

This is recognized as a “significant change” requiring lengthy PEP discussion - they’re not rushing this.

Common Questions

Will this change how I write Python code?

No. This affects only CPython internals. Your Python code will work exactly the same way. You might see performance improvements in certain operations, but the language semantics won’t change.

Is this confirmed?

Not yet. A PEP must be submitted and approved first. The project is targeting Python 3.16, but nothing is guaranteed until the community approves the proposal.

Why not rewrite everything in Rust?

Rome wasn’t built in a day, and neither is CPython. The gradual approach - selectively rewriting portions in Rust - minimizes risk while maximizing benefit. The C components that work well will remain C.

The Why Behind The How

I think the key insight is that this isn’t about replacing Python with Rust. It’s about giving Python better tools for the heavy lifting that happens behind the scenes. Python’s philosophy of simplicity and readability remains unchanged. What changes is the foundation it’s built on.

Rust’s memory safety guarantees mean fewer bugs and security vulnerabilities. Modern tooling means better development experience. Performance improvements mean faster Python code. These are real benefits that trickle down to every Python developer.

What This Means For You

If you’re a Python developer:

  • Your code won’t need to change
  • You might see performance improvements in future Python versions
  • Python becomes more maintainable and secure over time
  • The ecosystem stays Python-first - Rust is an implementation detail

If you’re interested in contributing or following the project:

  • Track the api-design label on GitHub for API discussions
  • Watch for the upcoming PEP (this is when the real community debate happens)
  • Target Python 3.16 beta in May 2027 for early testing

My Take

I think this is the right move for Python’s long-term health. C has served Python incredibly well, but the world has moved on. Rust gives CPython a path forward that maintains performance while adding safety and modern development practices.

The gradual, careful approach - CI builds across platforms, PEP process, community discussion - shows Python’s maturity. This isn’t a reckless rewrite; it’s a thoughtful evolution.

What do you think? Is Rust the right direction for CPython’s future?

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments