<johnjaye>
i'm reading some python code from pypy and I realized it's not python. it's rpython
<johnjaye>
like at one point it says globals()[foo]=bar which literally creates variables with the value of foo from a list of strings
<johnjaye>
also there's import statements that go import rpython.stuff
<johnjaye>
but supposedly any rpython is valid python. so maybe that's a valid python construct somehow
<larstiq>
right, rpython is a restricted subset of python
<johnjaye>
well i don't know too much about it. or how pypy works. is that heptapod repo the main pypy?
<mattip>
yes
<larstiq>
you _can_ run pypy on top of cpython, and this is in fact how many tests work (see https://doc.pypy.org/en/latest/coding-guide.html#id29, "By default, they run on top of an untranslated PyPy which runs on top of the host interpreter. ")
<mattip>
rpython is a subset of python2, so you need to use a python2 interpreter as the host
<mattip>
the reason it is a subset is so that the rpython code can be annotated and translated into C
<mattip>
so the definition of RPython is a bit fluid: anything that can be supported by the translation toolchain
<mattip>
so there are two modes to tests:
<larstiq>
where the rule of thumb is, the more dynamic it gets the less likely it's rpython?
<mattip>
- pure python tests ("own" tests) that run in python
<mattip>
- "translated" tests that run after translation
<mattip>
"the more dynamic it gets" - yes, for instance closures are not supported in RPython
johnjaye has quit [Ping timeout: 240 seconds]
johnjaye has joined #pypy
<arigato>
johnjaye: for the example of globals()[foo]=bar: that is very dynamic and not RPython at all if done inside a function, but we do that at import time. RPython is a two-step language: first, we import all modules and do sometimes very dynamic stuff to set up all functions and global constants etc., and then the remaining functions must not do anything dynamic any more, so that their code can be translated to efficient C code
<arigato>
in other words, globals()[foo]=bar is normal Python (you can do that in plain Python)
<fijal>
I just had the most strange pip invocation
<fijal>
as soon as I pressed enter, the power went off and it started hailing
<fijal>
like, as I pressed enter
<larstiq>
that's just a tad bit worse than my pip invocations stalling forever with the new resolver algorithm
<johnjaye>
arigato: oh ok so it's fine intially but then not afterward in any functions.
<johnjaye>
so if i understand rpython correctly, it is a subset of python where type inference is possible. this is then used with rpython libraries to make an interpreter for your language defined in EBNF or whatever.
xcm has quit [Quit: WeeChat 3.7]
xcm has joined #pypy
greedom has joined #pypy
greedom has quit [Remote host closed the connection]