Python disassembly

From Teknologisk videncenter
Jump to: navigation, search
heth@h5:~$ python3
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def add():
...     element=9
...     result=element+20
...     return(result)
...
>>> print(add())
29
>>> import dis
>>> dis.dis(add)
  2           0 LOAD_CONST               1 (9)
              2 STORE_FAST               0 (element)

  3           4 LOAD_FAST                0 (element)
              6 LOAD_CONST               2 (20)
              8 BINARY_ADD
             10 STORE_FAST               1 (result)

  4          12 LOAD_FAST                1 (result)
             14 RETURN_VALUE
>>>