3 ms·
CPython compiles to a byte code, too and runs that (https://devguide.python.org/internals/interpreter/ https://devguide.python.org/internals/interpreter/) Any
by Someone 3y ago
CPython compiles to a byte code, too and runs that (https://devguide.python.org/internals/interpreter/ https://devguide.python.org/internals/interpreter/)
Any speed difference between the two is because of a combination of
- developers spending less effort on making it fast
- differences in the virtual machines instruction set
- differences in the languages that make one harder to run fast
I think/guess the first is the major reason, but the instruction set may matter, too. The last one has at most a minor impact.
A reason developers spend less time making the CPython interpreter faster is that you can relatively easily make ‘python’ even faster by making it call C code.
- pyeri 3y agoBy "developers" you mean the core CPython developers here? Because CPython itself is very slow, Java runs circles around it on most benchmarks you'll find such as this one[1] from Debian. If you observe the computation time taken, the order of magnitude of difference between Java and Python programs is just preposterous! [1]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/python3-java.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- chalsprhebaodu 3y agoNode builds on top of V8, Chromium’s JS engine, which has JIT, which allows for some optimizations that aren’t as easy or obvious in a simple bytecode interpreter.
- Someone 3y agoThat’s exactly what I argue: the CPython developers choose not to spend time on a JIT (quite possibly because they didn’t have the resources to build a good one) PyPy shows Python could have had a JIT (https://www.pypy.org/ https://www.pypy.org/)