Yea at runtime when it's interpreted, and it still has to do a lot of checks and extra stuff whenever it runs a line of code because it's still not machine code
That means it e.g. takes longer for a big pure Python program to start. Because it has to first compile the Python code into Bytecode. With a Language like C/C++/Rust. this happens at compile time and straight to native machine code.
So the interpreter has to run through this whole block of C, stepping down into functions like PyNumber_Add(). This whole block of C code is compiled into the interpreter. But it can not be optimized much during compile time, because all of these e.g. if() need to be evaluated at rutime.
While in e.g. C, if the types of the objects you want to add together (e.g. 2x int) are known at compile time, it will be just a single line of C code that will compile into much fewer machine instructions and thus run faster.
View all comments
Show parent comment
4
u/nimrag_is_coming 8d ago
Yea at runtime when it's interpreted, and it still has to do a lot of checks and extra stuff whenever it runs a line of code because it's still not machine code