🛠 Python Disassembler¶
This tip is for you who like to bit diddling and understand what python does under the hood.
Python has a module that disassembles your code, that is, you can analyze the bytecode of your code!
⚗️ Test¶
Let's test it, for that we need to import the module called dis and use it as shown in the example below::
🔎 Explaining the result¶
| dis_example.py | |
|---|---|
- Importing
dislibrary. - Declare a function that adds two to a number.
- Calling Disassembly function to show us the bytecode.
- Pushes a reference to the local
co_varnames[var_num]onto the stack. Doc Link - Pushes
co_consts[consti]onto the stack. Doc Link - Implements
TOS = TOS1 + TOS. Doc Link - Returns with TOS to the caller of the function. Doc Link