Saturday, May 7, 2016

Disassembler for Python bytecode


It's possible to disassemble easely python bytecode. With python onboard tools. In this case the module 'dis'.



>>> def marcin(n):
...     print(n)
...
>>> import dis
>>> dis.dis(marcin)
  2           0 LOAD_GLOBAL              0 (print)
              3 LOAD_FAST                0 (n)
              6 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
              9 POP_TOP
             10 LOAD_CONST               0 (None)
             13 RETURN_VALUE
>>>

No comments:

Post a Comment