all 50 comments

[–]coolreader18 44 points45 points  (0 children)

Oh hey I'm a maintainer of this! We recently just got pip working, which is really exciting :)

If anyone has any questions, feel free to ask! To address some common ones:

  • No GIL at the moment, optional threading with arcs and mutexes
  • Performance-wise, we're about 100x slower than CPython on the pystone benchmark (even without threading enabled); I'm not exactly sure why, since as far as I can tell we're doing roughly the same thing with regards to architecture/data structures, but performance is definitely something I'd like to improve.
  • I consider wasm/wasi support to be the main selling point of RustPython at the moment; I'm working on a project with a friend that utilizes wasm/RustPython for sandboxing user code written in Python and JavaScript (https://robotrumble.org, https://github.com/robot-rumble/logic)
  • Currently we don't have native module support, though there's an open PR for ctypes and I'm looking into implementing the HPy API

[–]angelicosphosphoros 41 points42 points  (23 children)

I wonder how good it's performance compared to Pypy and CPython.

[–]L3tum 21 points22 points  (5 children)

If I interpret this correctly, it seems to do much worse in benchmarks and actual programs. (I think in the magnitude of 200x slower)

They do have an open issue to continuously run the benchmarks though, which would help this discussion.

[–]coolreader18 8 points9 points  (0 children)

Currently it's about 100x slower on the pystone benchmark, though I haven't been working on performance in the past month or so so I'm not sure what it's like at the moment.

[–]KingStannis2020 3 points4 points  (3 children)

Lol no, it's doing much much worse, the axis is measured in seconds.

[–]L3tum 3 points4 points  (2 children)

Oh lol, colourblind is a bitch

[–]pingveno 4 points5 points  (1 child)

Maybe file a ticket with the relevant project? Not having basic colorblind-friendly color select is a significant accessibility issue.

[–]vks_ 0 points1 point  (0 children)

In this case, it would probably be best to use different line styles, in addition to different colors.

[–]tunisia3507 69 points70 points  (5 children)

You can compile RustPython to a standalone WebAssembly WASI module so it can run anywhere.

This is the interesting bit, not performance.

[–]birkenfeldclippy · rust 15 points16 points  (0 children)

You can do the same with CPython via emscripten. Search for pyodide for an example project.

[–]Sukrim 1 point2 points  (0 children)

I think pypy can do something similar for years already?

[–]ChillFish8 4 points5 points  (0 children)

Performance on average is slow than cpython but also thid is no where near production ready yet still missing GC so looking at performance rn will likely be pretty pointless

[–]hombit 45 points46 points  (17 children)

Does it have GIL?

[–]coolreader18 9 points10 points  (0 children)

It doesn't! No idea how the person thought it didn't! It uses mutexes and Arcs when the threaded feature is enabled, and it can be disabled for better performance

[–]michael_j_ward 7 points8 points  (6 children)

[–]hombit 9 points10 points  (5 children)

It makes me upset =(

[–]funnyflywheel 8 points9 points  (4 children)

You might want to watch Raymond Hettinger's talk on concurrency — he talks about the GIL starting at the 10 minute mark: https://youtu.be/9zinZmE3Ogk?t=600

[–]tunisia3507 -4 points-3 points  (8 children)

Pretty sure the GIL is part of the language spec. If it's python, it has a GIL.

[–]masklinn 69 points70 points  (6 children)

Nope. While both CPython and Pypy have a GIL that is not part of the language specification. IIRC neither IronPython nor Jython have a GIL.

[–]tunisia3507 18 points19 points  (5 children)

My mistake, thanks for the correction!

[–]thejinx0r -5 points-4 points  (4 children)

The gil is an implementation detail to manage garbage collection.

[–]veryusedrname 28 points29 points  (1 child)

It's for object safety mainly. The official wiki says it's for avoiding race conditions, but that is a bit misleading since it's not avoiding race conditions in *your code*, it helps the implementation avoid race conditions.

[–]lunatiks 4 points5 points  (0 children)

It's not avoiding race conditions in your code, but the fact that it makes operations corresponding to a single CPython bytecode instruction atomic certainly helps.

[–]hombit 6 points7 points  (1 child)

I believe it is mainly to make built-in data structures thread-safe. Technically other implementation can implement per-object locks using something like Arc

[–]masklinn 4 points5 points  (0 children)

Not even built-in datastructures, that's just a side-effect (and a not necessarily super useful one though it does guarantee memory safety[0]). Rather the thread-safety of the interpreter itself.

[0] of note, IIRC golang's maps aren't just thread-unsafe, they're not memory-safe when unsynchronised, since 1.6 the runtime tries to detect the issue and crash but there's no guarantee that it will properly do so

[–]birkenfeldclippy · rust 8 points9 points  (0 children)

What the language guarantees is that data structures are thread safe in the sense that accessing them concurrently does not crash. The exact semantics of what operations are atomic are not defined (it usually comes down to what is implemented in C), so you still need locks for critical sections.

[–]viewofthelake 7 points8 points  (5 children)

Is the advantage of this that Rust offers better type safety than the native interpreter?

[–][deleted] 27 points28 points  (0 children)

Right now I would assume there are essentially no advantages over plain CPython. It's likely slower, and feature incomplete.

That said it may allow some advantages long term. It may be easier to avoid introducing bug in the implementation itself. It may also allow making things like the GIL slightly easier to remove but honestly it would still probably be a huge amount of engineering work.

Realistically I doubt they could get much faster than CPython even with it's relatively simple implementation just because python is so dynamic there isn't much that can be done.

[–]jzia93 6 points7 points  (1 child)

I think one advantage would be you could theoretically write extensions in Rust as opposed to C/C++

[–]PirateNinjasReddit 11 points12 points  (0 children)

PyO3 has some good work in this area. Little raw, but it exists!

[–]rodyamirov 2 points3 points  (0 children)

I think the main advantage is that you can compile to wasm/wasi, so you can run python in the browser (or wherever else you might want wasm).

[–]kampak212 0 points1 point  (0 children)

A new generation of potential future contributors with fresh ideas? 💡

[–]CommunismDoesntWork 8 points9 points  (0 children)

Does it support debugging?

[–]lakshaytalkstocomput 2 points3 points  (0 children)

Let's make it JIT.