What is meaning of "Python is executed line by line"?

When people say Python is executed line by line, do they referring to the SOURCE CODE or the BYTE CODE?

What exactly does the meaning of Python get executed line by line? Don’t other languages like Java do the same thing?

I am familiar with Java code execution in the JVM. What I can’t understand is this line-by-line execution of Python.

Good question! Who says it, and in what context?

2 Likes

What did those people tell you when you asked them?

Python source code (or bytecode) is not executed; instead, it is interpreted. On the other hand, Java is JIT-compiled and therefore executed.

One person’s interpreted is another person’s excuted.

Did you know that an Intel processor intreprets the X86 instruction set using
firmware that is running on dedicated hardware plus a risc like core?

The answer to the question is that from a python point of view the python
statements are compiled into byte code and its is the byte code that is executed.

Maybe the person claiming python is line by line is assuming that there are not optimisations that will “seem” to execute out of order. But I do not think that that
is sort of optimisation is not allowed.

1 Like

Python is actually executions statement by statement, which may be nested within statements, or on a more fine-grained level, logical-line by logical-line, each of which may be multiple physical lines.