102 points · by tvrvt · 4y ago · 36 comments
- Pythran (https://pythran.readthedocs.io) (ahead of time compiler) - mypyc (https://mypyc.readthedocs.io/en/latest/) (ahead of time compiler) - cython (ahead of time compiler) - Numba (JIT) - Pypy (An interpreter doing JIT compiling) - Nuitka (Ahead of time, IIRC)
At this point we should build a "Awesome Python Compilers" repo ... oh wait, it obviously already exists: https://github.com/pfalcon/awesome-python-compilers
e.g. PyPy doesn't work with PyTorch https://github.com/pytorch/pytorch/issues/17835
> We have stopped working on S6 internally. As such, this repository has been archived and we are not accepting pull requests or issues. We open-sourced the code and provided a design overview below to spur conversations within the Python community and inspire future work on improving Python.
> Python is slow, and a lot of researchers use Python as their primary interface to build models.
Why not just build models in JS?
Pytorch readme quote
pytorch is not a Python binding into a monolithic C++ framework. It is built to be deeply integrated into Python.
could be applied to many key libraries of this ecosystem.For sure, a lot of those libraries rely on tons of compiled code in C/C++/Fortran, but the python code is not mere wrapping on top of those libs. And most of the compiled code inside those repos has a lot of internal logic as well.
Some examples (using cloc on git main branch, as tokei does not understand cython):
* sklearn: 150 kloc python, ~10kloc cython, not much of other languages
* NumPy: 200kloc python, 350kloc for C/C++
* scipy: 800 kloc C, 200 kloc python (the 800kloc surprised me and it looks like a lot of it is C generated code from cython)It's more likely that something like Julia ends up replacing Python, even though I still believe it's a low probability thing.
I'm hopeful that honest efforts to port over useful bits of the scientific/mathematical ecosystem to JS will start to take off someday soon.
And have a look at, say, Julia.
Because ML/Data source has particular numerical requirements. JavaScript has poor mathematical defaults and still misses useful datatypes like float16*.
* Yes, this can emulated. Emulation is slow. You've gained some speed and then paid it back for emulation.
IMHO, you can't beat Python for ML by being just a slightly faster Python (there aren't enough newcomers for that, the Python ecosystem is enough to assimilate them before other languages can). You need to offer something more significant to make migration worthwhile. Julia tries to do that by allowing to implement the main stack in Julia, if it had JS speed and DX it would have eaten Python's lunch.