◐ Shell
clean mode source ↗

GH-106360: Support very basic superblock introspection by markshannon · Pull Request #106422 · python/cpython

def testfunc(x):
    i = 0
    while i < x:
        i += 1

testfunc(100)

for offset in range(0, 100, 2):
    try:
        ex = _testinternalcapi.get_executor(testfunc.__code__, offset)
        break
    except ValueError:
        pass

for uop in ex:
    print(uop)
('SAVE_IP', 7)
('LOAD_FAST', 1)
('SAVE_IP', 8)
('LOAD_CONST', 2)
('SAVE_IP', 9)
('_GUARD_BOTH_INT', 13)
('_BINARY_OP_ADD_INT', 13)
('SAVE_IP', 11)
('STORE_FAST', 1)
('SAVE_IP', 12)
('LOAD_FAST', 1)
('LOAD_FAST', 0)
('SAVE_IP', 13)
('COMPARE_OP_INT', 18)
('SAVE_IP', 15)