Comment by bb88
8 years ago
> - Write compilers from well-typed Python to native code.
That is one thing I really want to happen, because I think it begins to open up python to the embedded space. Micropython is nice, but it still needs an interpreter embedded into it.
There have been plenty of attempts to compile Python to faster code (usually by translating to C).
Cython can use type annotations and type inference to unbox numbers for faster numerical code, but uses ordinary Python objects otherwise. http://cython.org
ShedSkin translates a restricted (statically typeable) subset of Python to C++. https://shedskin.github.io
RPython has a multi-stage approach where you can use full dynamic Python for setup, but starting from the specified entry point, it is statically typed. Since it was created for PyPy, it comes with support for writing JIT compilers. https://rpython.readthedocs.io
Pythran translates a subset of Python with additional type annotations to C++. http://pythran.readthedocs.io
In general, the major hurdle for all attempts to compile Python to native code is that Python code is dynamically typed by default.
An hurdle that has been solved for quite some time in Lisp, Scheme, Prolog, Smalltalk, SELF (was the basis of Hotspot), Dylan, Ruby, JavaScript.
All not less dynamic than Python.
What Python lacks is the funding and willingness to actually push one of those implementations to eventually become the new reference implementation.
Nuitka might be interesting for this use case, too. http://nuitka.net/index.html
It will compile python to C++ and then compile that code to machine instructions and calls to the CPython library.
Thanks for that rundown. It's pretty good.