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

Function disassemble

Lib/dis.py:816–839  ·  view source on GitHub ↗

Disassemble a code object.

(co, lasti=-1, *, file=None, show_caches=False, adaptive=False,
                show_offsets=False, show_positions=False)

Source from the content-addressed store, hash-verified

814
815
816def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False,
817 show_offsets=False, show_positions=False):
818 """Disassemble a code object."""
819 linestarts = dict(findlinestarts(co))
820 exception_entries = _parse_exception_table(co)
821 if show_positions:
822 lineno_width = _get_positions_width(co)
823 else:
824 lineno_width = _get_lineno_width(linestarts)
825 labels_map = _make_labels_map(co.co_code, exception_entries=exception_entries)
826 label_width = 4 + len(str(len(labels_map)))
827 formatter = Formatter(file=file,
828 lineno_width=lineno_width,
829 offset_width=len(str(max(len(co.co_code) - 2, 9999))) if show_offsets else 0,
830 label_width=label_width,
831 show_caches=show_caches,
832 show_positions=show_positions)
833 arg_resolver = ArgResolver(co_consts=co.co_consts,
834 names=co.co_names,
835 varname_from_oparg=co._varname_from_oparg,
836 labels_map=labels_map)
837 _disassemble_bytes(_get_code_array(co, adaptive), lasti, linestarts,
838 exception_entries=exception_entries, co_positions=co.co_positions(),
839 original_code=co.co_code, arg_resolver=arg_resolver, formatter=formatter)
840
841def _disassemble_recursive(co, *, file=None, depth=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False):
842 disassemble(co, file=file, show_caches=show_caches, adaptive=adaptive, show_offsets=show_offsets, show_positions=show_positions)

Callers 2

distbFunction · 0.85
_disassemble_recursiveFunction · 0.85

Calls 10

findlinestartsFunction · 0.85
_parse_exception_tableFunction · 0.85
_get_positions_widthFunction · 0.85
_get_lineno_widthFunction · 0.85
_make_labels_mapFunction · 0.85
strFunction · 0.85
ArgResolverClass · 0.85
_disassemble_bytesFunction · 0.85
_get_code_arrayFunction · 0.85
FormatterClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…