3 ms·
> if you want it faster you should rewrite it in C. But I don't think such a drastic and destabilizing change is necessary. I've worked around the python linte
by user5994461 6y ago
> if you want it faster you should rewrite it in C. But I don't think such a drastic and destabilizing change is necessary.
I've worked around the python linter and it is written in C. The bits in python (especially our custom rules) were horribly slow.
Lint is building a tree of the code and going through it recursively. Going through a large tree in pure python is horribly slow, it has to interpret every single line of code again and resolve every variable again, because they could change anytime, the overhead is insane.
It's the one thing that python cannot do, parsing tree. If python had a JIT it might be doable but currently it isn't.
- xapata 6y agoTry PyPy.
- PaulHoule 6y agoNow that PyPy is up to Python 3.6 and has the bugs from the 3.5 series fixed I am using it for real work. The contextvars polyfill brings in the one thing I really need from Py 3.7. I have a toolkit that puffs up XML, JSON, whatever files into an RDF graph that has extra blank nodes that let you annotate anything. A year ago I was complaining about how slow it was, with PyPy it is 5 times faster and I am not complaining. I hear people get similar speed-ups for branchy monte carlo simulations too.
- Recursing 6y agoblack (the python auto formatter) uses mypyc https://github.com/python/mypy/tree/master/mypyc https://github.com/python/mypy/tree/master/mypyc
- rattray 6y agoThat looks exciting! Compiles mypy-annotated Python to a Python C extension. Claims a ~4x speedup, but still quite unstable/buggy, so who knows how much performance they'll have to give up for working software. Fingers crossed!