V8 made JavaScript fast in 2008, soon that will be 20 years ago.
Perhaps I live in a bubble, but so much of the production Python code I see is fully type-hinted and makes used of an aggressive linter & type checker to the point where it might as well be written in Go/C#/Java/TypeScript so that it can actually take advantage of the performance gains instead of being loaded into a runtime that turns everything into heap-allocated PyObject pointers.
[–] cpburns2009 2 days ago
[–] seabrookmx 2 days ago
[–] pjmlp 2 days ago
[–] throwaway7783 2 days ago
[–] _old_dude_ 2 days ago
Python interpreter is known to leak its implementation (__class_ modification after creation, monkey patching with __getattr__, sys._getframe, eval/exec, deterministic call to __del__, no proper python API for libraries, etc.)
You have to plug all of those holes before having a chance to get a decent JIT. Otherwise it will be just another JIT attempt, like Psyco, Unladen Swallow, Pyston.
[–] snovymgodym 2 days ago
V8 predates strict mode, and handles all the exec/eval, monkey patching and object system abuse you can do in JavaScript just fine. Common Lisp is one of the most dynamic languages in the world and allows you to do ridiculous things in terms of meta-programming and essentially building domain-specific languages into your program, yet it too manages to have ahead-of-time compiled implementations that are very performant. Also PyPy exists.
There are definitely some technical aspects that make it hard to make Python fast, but they are not insurmountable. The reason CPython is slow today is simply because performance has not historically been prioritized by its developers.
If I think about where I see python being used though, this kind of makes sense, the two big use cases are:
- Web APIs and backends, where for the most part either the network or the database is the bottleneck
- Data science work, where for the most part, work exists in libraries like polars, pytorch etc that ship the main work out to other languages.
So from that perspective, although we'd all like python do be faster, it's speed isn't the bottleneck in the use cases where its popular (that's probably also the reason why we don't see Python getting used in other speed critical places).
That's a really different story to JavaScript, which doesn't have a handy CFFI or otherwise you can just reach out to. There are a lot of cases where JavaScript speed improving would speed up the reactivity of a web app, even now.
I'm not arguing against a faster CPython - I'd love one! But I think there's a clear reason why it hasn't been prioritised historically in the way JavaScript's performance has.