3 ms·
The point is not to compile entire Python programs, the point is to optimize specific parts of Python that matters. To illustrate, consider a calculating sum of
by anon-3988 1y ago
The point is not to compile entire Python programs, the point is to optimize specific parts of Python that matters. To illustrate, consider a calculating sum of 1 to N in python
def sum(N):
x = 0
for i in range(N):
x += i
return x
There's absolute zero reason why this code has to involve pushing and popping stuff on the python virtual stack. This should be compiled into assembly with a small conversion between C/PyObject.
The goal is to get to a point where we can even do non-trivial things inside this optimized context.
Python will never be able to go down to assembly because Python support doing "weird shit" like dynamically creating modules, hell, even creating a Python file, running eval on that, and loading it as a new module. How are you even going to transpile that to assembly?
So I approach the problem the same way numba is approaching. But hopefully more modern and simpler (implementation wise). Planning on doing it using Rust and the backend should be agnostic (GCC, Clang, whatever C compiler there is)
- hayley-patton 1y ago> "weird shit" like dynamically creating modules, hell, even creating a Python file, running eval on that, and loading it as a new module. Expect that you don't, and deoptimise when you do: https://bibliography.selflanguage.org/_static/dynamic-deoptimization.pdf https://bibliography.selflanguage.org/_static/dynamic-deopti... It's really not that impossible.