2 ms·
> What word would you use to describe writing something in a language for illustration purposes? I'd probably go with "The GIL explained in Python". > PyPy i
by MaxBarraclough 8y ago
> What word would you use to describe writing something in a language for illustration purposes?
I'd probably go with "The GIL explained in Python".
> PyPy is written in RPython. You posted a link to the RPython translator's source code.
But RPython is a part of the PyPy project, no?
Do you consider the Wikipedia listing to be accurate?
- StavrosK 8y agoRPython is part of the PyPy project, yes. PyPy the interpreter is written in RPython. Parts of the RPython translator (maybe all of it, I'm not sure) are written in C. RPython is part of the PyPy project, but is not part of the interpreter (it just compiles it). I do consider the Wikipedia listing accurate, yes.
- yorwba 8y ago"PyPy" can mean two things: either the PyPy interpreter, or the PyPy project. The PyPy interpreter is written in Python, you could run Python on PyPy running on CPython if you wanted. (The PyPy folks probably do that regularly to debug the interpreter.) Because PyPy on CPython is never going to be faster than CPython alone, the RPython toolchain is used to convert the PyPy interpreter to C code. The C code in the RPython source (e.g. the GIL implementation) is bundled together with the translated program and then compiled into machine code. RPython is also written in Python. It works by importing the program to be translated, executing all initialization code to create classes, methods and global objects. This is no different from regular program startup. But then RPython is provided with a particular function as an entry point, and it does whole-program type inference to determine a static type for every reachable value. That only works because PyPy is written in a style that only uses dynamic Python features during initialization and is very restricted after the entry point. So PyPy is actually written in the subset of Python that RPython accepts. If you tried to use RPython on any arbitrary Python program, it'd probably complain about a ton of type errors. RPython is really a very different language, and its feature set is tailored specifically to writing PyPy in it. It can handle certain constructs that Mypy isn't able to typecheck because they require running the program, but it also rejects many well-typed Python constructs because they don't translate to efficient C.