|
|
|
|
|
by lukehutch
1864 days ago
|
|
How about instead aiming for 1000x as fast, so that it's as fast as a statically-typed language? (Google's pure Python Protobuf implementation is literally 1000x slower than their Python front-end that wraps the C++ Protobuf library...) Oh wait, achieving native speed is close to impossible for a dynamically-typed language. |
|
It's actually quite possible, and depends on the scenario.
A dynamically-typed language can analyse actual runtime type use and specialize function calls with a JIT, for example. It's also possible (and there's work in this area) to keep the specializations around for quick startup in the next runs... (and of course, drop them if they no longer hold).
That's how Javascript is much closer to native than Python - in some cases just 2-3 times slower than C. Lisp did very well too (better than more than a few static languages).
And that's with the extreme meta-programming / reflective behavior (which both Python and Javascript have). With less such, one could make a dynamic typing language that can be trivially JITed to run very close to native.