Live data from Hacker News

A Python interpreter rewritten in Rust, that can run pip

rustpython.github.io

31–40 of 53 posts

Re: A Python interpreter rewritten in Rust, that can run pip

#31

This uses [lalrpop]( https://github.com/lalrpop/lalrpop ) under the hood I believe, which is a pretty awesome parser generator library for Rust.

> LALRPOP in fact uses LR(1) by default (though you can opt for LALR(1)), and really I hope to eventually move to something general that can handle all CFGs (like GLL, GLR, LL(*), etc).

Seems overkill for a language whose grammar is LL(1)?

Re: A Python interpreter rewritten in Rust, that can run pip

#32
post #21

Earlier quoted context omitted.

Jython and IronPython don't have a GIL so you can see the effect there (it's not as bad as I thought it would be)

OK, I'll bite: how? They need some form of locking around Python objects accessed from multiple threads, since Python has no ownership model. Do they add a lock around each individual object?

Most languages with proper multithreading that I've used don't have an ownership model. Most the the standard library collection types are explicitly not thread safe, and then there's separate concurrent versions for if you're writing multithreaded code. And you're given locking/mutex primitives if you want to roll your own stuff.

Re: A Python interpreter rewritten in Rust, that can run pip

#33

Earlier quoted context omitted.

I suspect an interpreter that "solves" the GIL problem will break tons of modules that currently only work in concurrent contexts because the GIL exists.

Jython and IronPython don't have a GIL so you can see the effect there (it's not as bad as I thought it would be)

Jython and IronPython can work without a GIL more easily than CPython because they don’t support native (C-based) extension modules. Does RustPython intend to support existing Python extensions written in C?

Re: A Python interpreter rewritten in Rust, that can run pip

#38

This uses [lalrpop]( https://github.com/lalrpop/lalrpop ) under the hood I believe, which is a pretty awesome parser generator library for Rust.

Nice, long go the days (20 yrs ago) i had to make a JS transpiler with lex+yacc. The pain

had to? or got to? Sounds great, please tell us more.

Re: A Python interpreter rewritten in Rust, that can run pip

#39
post #23
post #21

Earlier quoted context omitted.

OK, I'll bite: how? They need some form of locking around Python objects accessed from multiple threads, since Python has no ownership model. Do they add a lock around each individual object?

> They need some form of locking around Python objects accessed from multiple threads, since Python has no ownership model. "Ownership models" are not a given. C++ has no "ownership model" and it doesn't lock around objects. Multi-threading users are just given the synchronization primitives and are expected to manage their own solutions. The same is true in Python: https://docs.python.org/3/library/threading.html#lo…

FreeBSD went through a similar issue back in the late 90s, early 2000s when they added pervasive multithreading into the kernel.

The GIL isn't some halting problem level thing. As you allude to, Python could definitely decide to go multithreaded and add in the requisite locks. They haven't.

I really wish that the PSF would

* Make a spec

* Break out the stdlib into a portable library, and by portable, something that can be shared across PyPy, Graal, Jython, etc.

* ??? yes

Re: A Python interpreter rewritten in Rust, that can run pip

#40
post #31

This uses [lalrpop]( https://github.com/lalrpop/lalrpop ) under the hood I believe, which is a pretty awesome parser generator library for Rust.

> LALRPOP in fact uses LR(1) by default (though you can opt for LALR(1)), and really I hope to eventually move to something general that can handle all CFGs (like GLL, GLR, LL(*), etc). Seems overkill for a language whose grammar is LL(1)?

Although the CPython implementation contains an LL(1) parser (which is being deprecated for a new PEG parser), the grammar contains bits that are not context-free, which involved a pre-parsing step before being fed into the LL(1) parser. That structure isn’t particularly good and it’d be beneficial for a new implementation to use something else.
Post reply on HN