4 ms·
Static typing does not make programs automatically faster. The compiler also needs to know typical patterns and apply optimized assembly code for these cases li
by G3rn0ti 5y ago
Static typing does not make programs automatically faster. The compiler also needs to know typical patterns and apply optimized assembly code for these cases like e.g. loop unrolling or binary arithmetic. Since typical python programs do not do number crunching much (NumPy delegates that to C routines), I wouldn't expect a great performance boost by a static compiler. Also note that statically compiled languages like Go e.g. still do a lot of run-time dispatching (due to the way interfaces work) which can not be removed by the compiler despite the presence of static types. Furthermore, much of perfomance is lost due to garbage collection that still needs to be done by a compiled python program. This why C programs will stay a thing when it comes to performance sensitive niches since it is fast due to the absence of language features.
I'd argue a good JIT compiler will always beat a static compiler, especially for a dynamic language using a complicated syntax such as python.