RustPython: A Python interpreter written in Rust
github.com
github.com
A Python Interpreter Written in Rust - https://news.ycombinator.com/item?id=19064069 - Feb 2019 (194 comments)
This post provided a great deep-dive anecdote on just that: https://news.ycombinator.com/item?id=28026562
Would love to hear how well it works, even anecdotally.
https://news.ycombinator.com/item?id=19064069 (February 2, 2019 — 430 points, 194 comments)
And technically iron oxide is already removed from the "true name": according to Graydon's recollection[0] it was named after the fungi[1].
[0] https://www.reddit.com/r/rust/comments/27jvdt/internet_archa...
The fungus looks a lot like pest eggs, so it was a relative relief to discover.
I was thinking on Ruston, I really like it and it's a word play with "a ton of rust" :)
That's Python's greatest weakness imo.
The main weakness in this repo seems to currently be lack of support for numpy/pandas and compatibility in general [0].
Almost every Python extension that I've ever read is littered with those calls (macros?), which I'd expect adds up to a decent amount of contention.
Practically speaking, I/O is usually the bigger bottleneck. Or you can change your algorithm to not share memory, then use multiprocessing, or a task scheduler like celery to spread it over multiple machines.
There are a ton of people who hear about someone running into GIL issues and they think it is affecting them, when they're not doing anything that would be helped by removing it. A JIT compiler on the other hand, would speed up every Python program.
The Standard CPython first compiles to bytecode, then the interpreter translates every instruction as it is ran to the correct instruction for the local platform.
A JIT like this, or PyPy compiles to bytecode, then compiles (some of?) the bytecode to the correct local instructions before running. This means it doesn't need to translate every instruction as it runs.
Projects like Nuitka/Cython compile ahead of time for the platform. So you would either distribute binaries, or have them be compiled at install time.
In any case the only point I was making is that if they made a one to one translation of CPython to RustPython it would not make much of a difference. However, the fact that they are working on a JIT definitely would.
As far as wasm, I beleive it is just building the entire RustPython interpreter as a WASM package. Which I guess would be so you could load it into a browser and then use it to interpret your python code. I suspect this approach would likely be slower than all of the above. Or at the very least be highly dependent on the Browser it is running in.
Other problem with rewriting the interpreter in Rust, though, is now you lose all the already actually fast third party modules like NumPy, PyTorch, TensorFlow, and what not that all rely on having the internal API to call C, Fortran, and CUDA. Until someone writes a CUDA interface in Rust and a BLAS implementation at least equal to OpenBLAS, if not MKL, but that doesn't seem to be a priority for NVIDIA or the scientific and numerical computing communities, who seem to be focused on Julia if they're not happy with Python, R, and MATLAB.
The threading semantics and general dislike for global state seem like they'd make that more likely, although the C API could make that a more difficult proposition, even in its modern "restricted" forms.
Do you? Rust can work with C ABIs; why wouldn't it be able to do a passthrough for Python?
Which they can do, but that is a heck of a lot more work than just writing a Python interpreter.
See: https://docs.python.org/3.10/c-api/index.html and https://www.pypy.org/posts/2018/09/inside-cpyext-why-emulati...
There are many workarounds, but the Gil is still there.
If there will ever be a python 4 with breaking changes, I hope it will be to implement proper gil-less operation.
There was an attempt (I think in PyPy) to use Software Transactional Memory (STM) which would solve this problem, but apparently it is still difficult to do it and looks like it did not succeed.
If you're doing computation, you're still locked to a single thread by the GIL.
Yeah you can use multi-processing, but now you're paying the price of inter-process communication.
1: https://github.com/oracle/graalpython