List of python topics of interest.

Understanding dis.dis

In [1]: f1 = lambda: (1, 2, 3, 4, 5)

In [2]: f2 = lambda: [1, 2, 3, 4, 5]

In [3]: import dis

In [4]: dis.dis(f1)
  1           0 LOAD_CONST               1 ((1, 2, 3, 4, 5))
              2 RETURN_VALUE

In [5]: dis.dis(f2)
  1           0 LOAD_CONST               1 (1)
              2 LOAD_CONST               2 (2)
              4 LOAD_CONST               3 (3)
              6 LOAD_CONST               4 (4)
              8 LOAD_CONST               5 (5)
             10 BUILD_LIST               5
             12 RETURN_VALUE

PEP 572

Python interpreter

BACK TO TOP
Post tagged with: python