In principle, there is a main reason for all this: the number of instructions that need to be done for something.
In direct old C, most statements can be completed with just a few instructions, usually from just over 1 to about 4, and with an average value that can be close to 1.
In C ++, more happens on the covers, for example, calling a virtual method requires a few more instructions. Come on, this may be resolved by a good optimizer, but runtime type information may interfere with the optimizer.
In Java, you have the same problems, plus the code runs in an interpreter that extends each JVM instruction to one or more machine instructions - in some cases much more, especially if the code does not work long enough to take advantage of runtime options.
And Python has all these problems, but it needs to be analyzed at startup and has a flexible (more complex) type management system, which means a few more instructions.
Yes, Python can be compiled. There are even projects that try it . But hard compilation robs you of some of the benefits of dynamic languages.
source share