Python Forum

Full Version: REPL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.