MCPcopy Index your code
hub / github.com/python/cpython / dis

Method dis

Lib/dis.py:1099–1136  ·  view source on GitHub ↗

Return a formatted view of the bytecode operations.

(self)

Source from the content-addressed store, hash-verified

1097 return _format_code_info(self.codeobj)
1098
1099 def dis(self):
1100 """Return a formatted view of the bytecode operations."""
1101 co = self.codeobj
1102 if self.current_offset is not None:
1103 offset = self.current_offset
1104 else:
1105 offset = -1
1106 with io.StringIO() as output:
1107 code = _get_code_array(co, self.adaptive)
1108 offset_width = len(str(max(len(code) - 2, 9999))) if self.show_offsets else 0
1109 if self.show_positions:
1110 lineno_width = _get_positions_width(co)
1111 else:
1112 lineno_width = _get_lineno_width(self._linestarts)
1113 labels_map = _make_labels_map(co.co_code, self.exception_entries)
1114 label_width = 4 + len(str(len(labels_map)))
1115 formatter = Formatter(file=output,
1116 lineno_width=lineno_width,
1117 offset_width=offset_width,
1118 label_width=label_width,
1119 line_offset=self._line_offset,
1120 show_caches=self.show_caches,
1121 show_positions=self.show_positions)
1122
1123 arg_resolver = ArgResolver(co_consts=co.co_consts,
1124 names=co.co_names,
1125 varname_from_oparg=co._varname_from_oparg,
1126 labels_map=labels_map)
1127 _disassemble_bytes(code,
1128 linestarts=self._linestarts,
1129 line_offset=self._line_offset,
1130 lasti=offset,
1131 exception_entries=self.exception_entries,
1132 co_positions=co.co_positions(),
1133 original_code=co.co_code,
1134 arg_resolver=arg_resolver,
1135 formatter=formatter)
1136 return output.getvalue()
1137
1138
1139def main(args=None):

Callers 15

test_exception_tableMethod · 0.80
check_stack_sizeFunction · 0.80
get_disassemblyMethod · 0.80
get_disassemblyMethod · 0.80
test_is_op_formatMethod · 0.80
test_disassembledMethod · 0.80
check_disMethod · 0.80

Calls 9

_get_code_arrayFunction · 0.85
strFunction · 0.85
_get_positions_widthFunction · 0.85
_get_lineno_widthFunction · 0.85
_make_labels_mapFunction · 0.85
ArgResolverClass · 0.85
_disassemble_bytesFunction · 0.85
FormatterClass · 0.70
getvalueMethod · 0.45

Tested by 15

test_exception_tableMethod · 0.64
check_stack_sizeFunction · 0.64
get_disassemblyMethod · 0.64
get_disassemblyMethod · 0.64
test_is_op_formatMethod · 0.64
test_disassembledMethod · 0.64
check_disMethod · 0.64