So I lately came across an explanation for Python's interpreter and compiler (CPython specifically).
Please correct me if I'm wrong. I just want to be sure I understand these specific concepts.
So CPython gets both compiled (to bytecode) and then interpreted (in the PVM)? And what does the PVM do exactly? Does it read the bytecode line by line, and translate each one to binary instructions that can be executed on a specific computer? Does this mean that a computer based on an Intel processor needs a different PVM from an AMD-based computer?
if/else statement like "if the current instruction is this, do this; if the instruction is this, do another thing", and so on. Instructions aren't translated to binary - that's why it's called an interpreter.
if/else statement to decide what instruction it's looking at. For example:
curr_byte = read_byte()
if curr_byte == 0x00:
# Parse instruction with no arguments
curr_instruction = DO_THING_A;
args = NULL;
elif curr_byte == 0x01:
another_byte = read_byte()
if another_byte == 0x00:
# Parse a two-byte instruction
curr_instruction = DO_THING_B;
args = NULL;
else:
# Parse a one-byte instruction
# with one argument
curr_instruction = DO_THING_C;
args = another_byte >> 1; # or whatever
elif curr_byte == ...:
... # go on and on and on