Python Forum
REPL - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: REPL (/thread-23605.html)



REPL - grkiran2011 - Jan-08-2020

Hi,

The Python REPL is it an interpreter or a compiler?

When I have a file, let's say test.py and when I type, python test.py at the command prompt, the file get's compiled into byte code and then gets executed by the PVM.

But the same code if I input via the REPL, does it still compile and then execute or does it interpret line by line and execute?

Please clarify.

Thanks


RE: REPL - Gribouillis - Jan-08-2020

When you type code in the REPL, each python statement is compiled into bytecode individually and this small bytecode is immediatly executed. Of course these statements can span multiple lines for example if you're writing a loop or a function definition.