[Chennaipy] Chennaipy - Monday Module - 05 Sep 2022
selvi dct
selvi.dct at gmail.com
Mon Sep 5 14:05:35 EDT 2022
Date: 05 Sep 2022
Module: dis
Installation: pip install dis
About:
The dis module supports the analysis of CPython bytecode by disassembling
it. The CPython bytecode which this module takes as an input is defined in
the file Include/opcode.h and used by the compiler and the interpreter.
Source Code:
import dis
def print_hello(string):
print("Hello", string)
# This will display the disassembly of print_hello
dis.dis(print_hello)
Output:
4 0 LOAD_GLOBAL 0 (print)
2 LOAD_CONST 1 ('Hello')
4 LOAD_FAST 0 (string)
6 CALL_FUNCTION 2
8 POP_TOP
10 LOAD_CONST 0 (None)
12 RETURN_VALUE
Reference:
https://pypi.org/project/dis/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/chennaipy/attachments/20220905/e942b950/attachment.html>
More information about the Chennaipy
mailing list