In 32.12. dis — Disassembler for Python bytecode — Python 3.6.3 documentation, there's an example saying:
Example: Given the function myfunc():
def myfunc(alist):
return len(alist)
the following command can be used to display the disassembly of myfunc():
>>> dis.dis(myfunc)
2 0 LOAD_GLOBAL 0 (len)
2 LOAD_FAST 0 (alist)
4 CALL_FUNCTION 1
6 RETURN_VALUE
I can understand LOAD_GLOBAL CALL_FUNCTION and RETURN_VALUE
What's the meaning of LOAD_FAST
According to the Python dis docs:
LOAD_FAST(var_num)
Pushes a reference to the local co_varnames[var_num] onto the stack.
So, in your case, the LOAD_FAST instruction loads alist to be able to pass it to the global len function:
return len (alist)
RETURN_VALUE LOAD_GLOBAL LOAD_FAST
< CALL_FUNCTION >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With