3 ms·
Please forgive my ignorance, but how would this be useful? I am not familiar with compilers or what having bindings in Python to a compiler would help.
by bmh100 10y ago
Please forgive my ignorance, but how would this be useful? I am not familiar with compilers or what having bindings in Python to a compiler would help.
- thomaslee 10y agoYou could, for example, write a compiler in Python that generated native code (or LLVM bitcode to be passed to llc or whatever) via the LLVM API. Writing a compiler in Python vs. C/C++ would be a lot easier in a number of ways. I'm not aware of any "production grade" compilers that do this, but no hard reason why not, I guess. Seems like it'd be nice for prototyping etc. if nothing else.
- Tempest1981 10y agoMore on what Thomas said: http://www.llvmpy.org/ http://www.llvmpy.org/
- bootload 10y ago"This project has been deprecated and is no longer being actively developed. We strongly suggest migrating to llvmlite. " try http://llvmlite.pydata.org/en/latest/ http://llvmlite.pydata.org/en/latest/ explanation why http://llvmlite.pydata.org/en/latest/intro/index.html http://llvmlite.pydata.org/en/latest/intro/index.html
- grej 10y agoCheck out numba. It does this for a subset of Python.
- bmh100 10y agoSo could I use this to conveniently optimize frequently called or inner loop functions?
- m_mueller 10y agoWant to make an obscure (your own?) language faster or extend it for your usecase? Write a frontend in python and let llvm do the hard parts.
- exDM69 10y agoTwo big use cases are building your own compiler in Python and doing some JIT compilation (E.g. regex matcher or similar) to gain some perf. LLVM is fantastic but not everyone wants or can use C++ in their project. I've been doing prototype compilers in Haskell, but Python might also be a nice choice.