Disassembling Code
Learn about disassembling code.
We'll cover the following...
dis
module
Sometimes, it helps to have a microscopic view of some part of the code. When that is the case, I find it better to rely on the dis
module to find out what’s going on behind the scenes. The dis
module is a disassembler for Python byte code. It is
simple enough to use:
Press + to interact
import disdef x():return 42dis.dis(x)
The dis.dis
function disassembles the function that you passed on as a parameter, and prints the list of bytecode instructions that are run by the function. It can be useful to understand what’s really behind each line ...