August 2nd, 2024

RustPython: A Python Interpreter Written in Rust

RustPython is a Python implementation in Rust, using a modified CPython 3.7 standard library. The project currently focuses on the `unittest` module for testing with the CPython test suite.

Read original articleLink Icon
RustPython: A Python Interpreter Written in Rust

RustPython is a Python implementation written in Rust, and its GitHub repository includes the standard library primarily sourced from the CPython 3.7 branch, with some modifications for compatibility. These modifications are minimal, aimed at fixing bugs and addressing missing features in RustPython. The project's current focus is on the `unittest` module, which will enable the team to use the CPython test suite for testing purposes.

Link Icon 18 comments
By @stavros - 9 months
I don't understand how it's possible that we just randomly come across a project that just casually implements a Python interpreter in Rust. Don't these things take a massive amount of effort? Wouldn't this be making waves much earlier in its development process?

I feel the same way about Ruff, for example. One day it was "black all the things" and the next it's "btw we just reimplemented the entire Python formatting/linting ecosystem in Rust, and it's 100x faster, no biggie".

What's happening? Is it just so much easier to write stuff in Rust that projects like these pop out of people's heads, fully-formed? It boggles the mind.

By @pornel - 9 months
By @pbronez - 9 months
Interesting that it relies on OpenSSL, either dynamically from the OS or vendored at compile time. I wonder what the implications would be for using something like rustls. You’d get TLS batteries included and kill a large external dependency… but possibly introduce behavior changes to low-level cryptographic operations, which is scary.

Still, the maintainers stated that they don’t plan to implement Python’s readline module because they already have a rust implementation of readline. A similar argument could apply here - use native rust implementations of dependencies and expose them via the expected Python APIs. This would break some ambitious Python programs, but those probably wouldn’t consider alternative runtimes anyway.

https://github.com/rustls/rustls

By @nextaccountic - 9 months
Does numpy runs on rustpython? And other libraries used in ML (not expecting compatibility with huge libraries like torch or tensorflow, but rather, getting the leaves to work should be doable)

If not, is it at all possible to get numpy to work and other libraries written in native code? I see that rustpython also work in wasm: but what about compiling numpy's native code to wasm as well?

By @upbeat_general - 9 months
Does this have faster startup times than cpython?

Every time I want to rewrite a shell function in python, I always hesitate due to the slow startup.

By @nickpsecurity - 9 months
I wonder if this would make Python web applications more secure at interpreter and library level.

Running it on hardened Linux, OpenBSD, or FreeBSD was a start. A Rust implementation might help.

I also miss setups like eCos RTOS where a GUI determined which features got compiled in. Strip each Python app down to just what it needs in the interpreter. Might squeeze it in L1-L2 cache that way, too. Aside from embedded (eg MicroPython), has anyone anything like that for use on servers?

By @pipeline_peak - 9 months
If Rust makes its way into the Linux Kernel, another mature C project, I wouldn’t be surprised if a Rust interpreter replaces CPython.
By @jeden - 9 months
https://notes.eatonphil.com/lua-in-rust.html It's some kind of developer trend.
By @Zamiel_Snawley - 9 months
I don’t see it on the main read me, what are the limitations/incompatibilities with CPython at this point in time? How “drop in ready” is it?
By @jbernsteiniv - 9 months
Does RustPython support the GIL? It would be ironic for a language with a crab as a mascot to not depend on having gills or at least one.
By @hughdbrown - 9 months
There's no installable version for pyenv. In general, how well does this work with virtualenvs?
By @abdullahalharir - 9 months
Are there any benchmarks made public in comparison with the python3 interpreter?
By @jeden - 9 months
We waiting for Ruby ;)
By @jedisct1 - 9 months
A Python interpreter has to be written in every language.
By @iamgopal - 9 months
Is there GoPython ?
By @cutler - 9 months
While you're at it fix Python's crippled lambdas and ...
By @bitzun - 9 months
This project doesn't seem to be adhering to the terms of the license of the original CPython modules that have been copied into its source repository.
By @jdeaton - 9 months
does it have a GIL