Python executable compiled from source code at ‣ see Working w/ Source Code on how to build

Starting with just few lines of code in test.py which does a simple addition before printing result

a = 8
b = 4
c = a + b
print(c)

Now, the python disassembler can show us what operations are happening wrt every line of code, and dis can be found at ‣

Disassembling code

running dis on code is simple as well

image.png

the first column is line number wrt script, next is the instruction then the value given to that op

Understanding disassembly w/ Bytecode Instructions

Value Stack

the value stack is what the intructions/ops work on like they pop the top to get some values and similarly push values into the stack

Line 0

RESUME is a no-op which doesn’t do anything

Line 1 & 2

instead of LOAD_CONST , LOAD_SMALL_INT is used, which is an optimization for small integers under 256