logoalt Hacker News

everforwardyesterday at 5:53 PM1 replyview on HN

I know of a couple reasons offhand.

JavaScript is JIT’ed where CPython is not. Pypy has JIT and is faster, but I think is incompatible with C extensions.

I think Pythons threading model also adds complexity to optimizing where JavaScripts single thread is easier to optimize.

I would also say there’s generally less impetus to optimize CPython. At least until WASM, JavaScript was sort of stuck with the performance the interpreter had. Python had more off-ramps. You could use pypy for more pure Python stuff, or offload computationally heavy stuff to a C extension.

I think there are some language differences that make JavaScript easier to optimize, but I’m not super qualified to speak on that.


Replies

pansa2yesterday at 6:49 PM

> I would also say there’s generally less impetus to optimize CPython

Nonetheless, Microsoft employed a whole "Faster CPython" team for 4 years - they targeted a 5x speedup but could only achieve ~1.5x. Why couldn't they make a significantly faster Python implementation, especially given that PyPy exists and proves it's possible?

show 1 reply