6 ms·
LLVM Python
- andrewcooke 13y agofor a moment there i thought this was a new attempt at unladen swallow... [if you've not clicked, it's a python lib to access llvm tools] http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospective.html http://qinsb.blogspot.com/2011/03/unladen-swallow-retrospect...
- deleted 13y ago[deleted]
- menssen 13y agoBased on the word shape of the domain, please tell me that this is pronounced "lumpy." If not, it should be.
- derleth 13y ago"llvmpy" kind of looks like an Ancient Roman trying to write down a Welsh word. And for good reason: The 'v' glyph was used for both the 'v' sound and the vowel 'u' sound before 'u' became its own letter.
- boomzilla 13y agoI'm curious, is there a Python to native executives compiler/builder?
- iskander 13y agoYes, Nuitka (http://nuitka.net/ http://nuitka.net/) and Cython (http://cython.org/ http://cython.org/) both compile a Python program to a chain of C API calls. The performance benefit isn't typically all that large, since removing dispatch overhead isn't really a huge deal compared to using more efficient data representations. Cython has the additional benefit that it lets you declare some typing assumptions, which then enables serious performance gains. There are also runtime compilers for Python subsets such as Numba (http://numba.pydata.org/ http://numba.pydata.org/) and Parakeet (https://github.com/iskandr/parakeet https://github.com/iskandr/parakeet), which can potentially give you huge speedups (as long as you stay within the world of numerical/array-oriented code).
- glogla 13y agoI have experience with Cython, and it works pretty well -- you basically use python code, but add some type hints and it will compile and get quite faster. Of course, it will not be as fast as normal C, because it still uses smarter (but slower) Python data structures, but it provides nice middle ground between pure python or PyPy, and writing the performance critical-part of your software in C by hand, which is bit more work, especially if you need to transfer multidimensional arrays between C and Python.
- antihero 13y agoCan you use this to write, say, high-performance webapps and/or database drivers?
- njharman 13y agoYou can use any Python to write high-performance webapps cause the performance requirements for "webapps" is low and the backends are usually servers/services and/or are more constrained by datastructures/algorithm/disk than execution speed.
- iskander 13y agoI think you might have evaded the question :-). There really are some "webapps" with tight performance requirements. For example, Google's web frontend is a statically compiled C++ application. And yes, anithero, you could write that sort of thing in Cython and with some type declarations get acceptable native performance. You will probably miss a few opportunities for optimization but catch the low-hanging fruit and get an orders of magnitude speedup over Python.
- antihero 13y agoInteresting. I was actually thinking of using something like this to take parts of the slower web frameworks that have tonnes of functionality, such as Django's ORM or templating, and get them on par with microframeworks.
- simula67 13y agoI think you may have shedskin ( https://code.google.com/p/shedskin/ https://code.google.com/p/shedskin/ ). I seem to remember performance wise the RPython guys seems to think a JIT implementation of Python would be faster because of the dynamic nature of Python.
- deleted 13y ago[deleted]
- takluyver 13y agoExtra info: these bindings are what Numba is built on. That's why it's maintained by Continuum Analytics, the people behind Numba.
- iskander 13y agoIn particular, a lot of was written by Siu Kwan Lam (https://github.com/sklam https://github.com/sklam), who doesn't seem prone to taking public credit but has been quietly doing an awesome job.
- pjmlp 13y agoNice tooling for writing compilers. :)
- zubspace 13y agoDoes this mean, that we're able to translate python into javascript with emscripten or is there additional work to do? (https://github.com/kripken/emscripten/wiki https://github.com/kripken/emscripten/wiki) Edit: Furthermore, how practical is this?
- maximilian 13y agoThis is not a compiler that does python -> llvm. It is a way to build llvm IR from python using the C++ API. Otherwise you output LLVM IR as text, and call the llvm command line tools to do stuff with it. For example, you can use this to generate LLVM IR at runtime, and use the LLVM JIT to compile and execute that LLVM code.