Python Analysis tools

Bytecode inspection

In [1]:
from dis import dis
dis('{1}')
  1           0 LOAD_CONST               0 (1)
              2 BUILD_SET                1
              4 RETURN_VALUE
In [2]:
dis('set([1])')
  1           0 LOAD_NAME                0 (set)
              2 LOAD_CONST               0 (1)
              4 BUILD_LIST               1
              6 CALL_FUNCTION            1
              8 RETURN_VALUE

Breakpoint debuggin

In [4]:
import pdb

# Put the following where you want to break
# pdb.set_trace()
In [ ]: