This boils down to the fact that at the compilation stage there is less information to work with, and therefore the runtime should do more work in the case of duck typed (dynamically typed) languages.
Thus, if I make a call to the foo.bar () method, in the case of Java or C ++, the call to bar can be optimized during compilation by opening the type βfooβ and then directly calling the method in memory, where the compiler knows that he will be found. Since python or any other dynamically typed language compiler does not know what type the foo object belongs to, it must perform type checking at runtime, and then look up the address of the bar method and then call it.
There are other difficulties that the python writer / compiler encounters, although one of them, we hope, gives adequate guidance. Thus, even with the best compiler authors, statically typed languages ββare likely to work much better at runtime.
If dynamically typed language ratings are usually under development. Due to fewer lines of code for writing and maintaining, and also not for compiling wait times for developers, development often goes much faster.
Dhananjay Nene Mar 23 '09 at 12:19 2009-03-23 ββ12:19
source share