Skip to main content

Practice ยท 1 of 1

Programmatic disassembly

Implement two helpers using dis.get_instructions (NOT dis.dis, which prints): 1. instruction_names(func) โ€” list of opname strings in execution order. 2. loop_loads_global(func, name) โ€” True when the bytecode contains at least two LOAD_GLOBAL instructions (i.e. a lookup likely inside a loop rather than one-time setup). The graded cases include a function that re-loads a global per iteration and one that binds it to a local first.

Difficulty: advanced

Back to lesson: Practice: Bytecode Practice