3 ms·
Interesting, this is very similar to llvmlite.Builder which is a wrapper over llvm. I am probably going to create something similar for my Python -> C -> assemb
by anon-3988 1y ago
Interesting, this is very similar to llvmlite.Builder which is a wrapper over llvm. I am probably going to create something similar for my Python -> C -> assembly JIT.
- Twirrim 1y agoThere's also libgccjit, https://gcc.gnu.org/wiki/JIT https://gcc.gnu.org/wiki/JIT, though all of the third party language bindings appear to be stale for it.
- globalnode 1y agothat project sounds interesting as well, but what do you do with libraries in python.. have the generated C code translate back to python calls?
- anon-3988 1y agoThe 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.
- lhames 1y agoThe LLVM ORC and Clang-REPL projects would be worth checking out if you haven't already: there's a healthy community of high performance computing folks working in this space over at https://compiler-research.org https://compiler-research.org. In particular, this talk might be interesting: "Unlocking the Power of C++ as a Service: Uniting Python's Usability with C++'s Performance" Video: https://www.youtube.com/watch?v=rdfBnGjyFrc https://www.youtube.com/watch?v=rdfBnGjyFrc Slides: https://llvm.org/devmtg/2023-10/slides/techtalks/Vassilev-UnlockingThePowerofCppAsAService.pdf https://llvm.org/devmtg/2023-10/slides/techtalks/Vassilev-Un...
- almostgotcaught 1y agoit's mostly upstream now, no need to dig around in their repos https://github.com/llvm/llvm-project/tree/main/clang/tools/clang-repl https://github.com/llvm/llvm-project/tree/main/clang/tools/c...