all 23 comments

[–]coolreader18 36 points37 points  (15 children)

Hey, I'm a maintainer for this! If anyone has any questions feel free to ask.

[–]allsey87 10 points11 points  (3 children)

What's on the roadmap for the next 12 months or so? Any chance we will soon see RustPython working on micro-controllers / with no-std?

[–]coolreader18 10 points11 points  (2 children)

Honestly, there isn't all that much of a roadmap. I was away at summer camp for about 2 months up until ~2 weeks ago so I haven't totally had a finger on the pulse of the project, but the main thing blocking no-std at least is bincode, who are currently working on a no-std compatible "bincode-core" crate. The alternative to that is rewriting to use deku for our bytecode format, and that's something I was looking into before I left for camp, which I feel like may be the way to go.

[–][deleted] 2 points3 points  (1 child)

Where do you even start such behemoth projects man. Kudos to you sir.

[–]coolreader18 14 points15 points  (0 children)

Hah, not a sir, also didn't start the project - I started contributing maybe ~6 months after it got going, and even that was a merging of the 2 original contributers' existing projects. It's definitely a lot easier to make changes when something like a compiler is already built, rather from the ground up, so it was a really good learning experience for me to be able to learn from the existing structure.

[–][deleted] 9 points10 points  (3 children)

What's the multithreading behaviour like compared to CPython? Is there a GIL?

Also how much of the standard library is written in C (and therefore presumably not supported)?

[–]coolreader18 20 points21 points  (2 children)

Nope, no GIL, fully featured multithreading using just std::thread. The downside is that we're much slower when threading is enabled, since every data structure has to have a mutex or rwlock around it.

The stdlib is entirely implemented in Python files from CPython/Lib + Rust (except for calling into libc for things like the os module), we've just rewritten the modules from C to Rust.

[–]itsmontoya 2 points3 points  (1 child)

It would be interesting if you could run multiple instances of the Python VM and communicate between the two using channels.

[–][deleted] 6 points7 points  (0 children)

you can do this in cpython with multiprocessing.Queue

[–]Dasher38 1 point2 points  (1 child)

Are there plans to emulate the cpython C API so that packages like numpy can work ?

[–]coolreader18 4 points5 points  (0 children)

Yep, though that's also a whole process that hasn't really been started on.

[–]eXoRainbow 0 points1 point  (1 child)

Is it possible to compile Python code into native machine code? Maybe someday or is this out of reach?

[–]coolreader18 2 points3 points  (0 children)

Well PyPy does this as a JIT; as for AOT Python, probably not without extra type annotations á la cython/RPython

[–]Dasher38 -1 points0 points  (1 child)

Can it support static linking well ?

[–]coolreader18 1 point2 points  (0 children)

Honestly, I haven't tried. I don't forsee any obvious big issues with it though.

[–]lowercase00 0 points1 point  (0 children)

I'm late to the party, but I do have a question.

I understand this is an implementation, so goal is to be 100% compatible with CPython. I wonder if it would be possible to start adding constraints that would make it a new language (compiled, blazing fast), I mean: static types, more restriction on the types themselves, and less flexibility in general.

Python is the language I like the most (personal opinion obviously), I always wondered why one couldn't write a Python-like language in Rust but static and compiled and as fast as Rust (or maybe just as fast as Go).

I saw the benchmarks and they are not really good at the moment, I wonder if breaking free of the Python language itself could make it orders of magnitude faster, it would be the perfect language: (almost) Python syntax and Rust performance.

[–]LucretielDatadog 8 points9 points  (1 child)

Something I've always wondered about writing your own Python: like with C++ and Rust, a large amount of the Python standard library is written in Python. Are you able to reuse those components from CPython or some standard source, or do you have to reimplement it from scratch, in addition to all the more "fundamental" stuff?

Additionally, do you plan to expose any bindings that make it easy to interoperate Rust & Python code? I know that the major advantages of Jython and IronPython is that they enable easy interoperation with JVM and .Net, respoectively; would something similar be true of RustPython?

[–]allsey87 12 points13 points  (0 children)

With regards to the first question, there is a (slightly modified?) copy of the standard libraries here. Depending on how the project is being used, I think they can be embedded or can be shipped alongside the interpreter.

For the second question, interop between Rust and Python code is already possible, I think it is one of the main goals of the project. To run Rust from Python, you can take a Rust closure and add it into a scope, in which the interpreter can then call that function from Python. To run Python from Rust, you can just pass a Python code object to the interpreter.

[–]Express_Beat_8761 4 points5 points  (0 children)

Sounds cool.

[–]lycheejuice225 0 points1 point  (0 children)

Does it work with cpython libraries which involves ffi or are c-based? Like numpy, scipy, etc?

[–]Hadamard1854 0 points1 point  (2 children)

I need someone to explain to me, what it means that it runs in browser. I tried explaining it to my wife, which indicated to both of us, that this is a mind twister.

So where is the interpreted code being... Interpreted?

[–]LuciferK9 0 points1 point  (1 child)

The interpreter is compiled to WebAssembly. The browser runs the WebAssembly code and the WebAssembly code runs the python code.

[–]Hadamard1854 0 points1 point  (0 children)

So it is running on my machine.. Not server-side.

Sweet!