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

Function iter_pre_succ_pairs_tables

Tools/scripts/summarize_stats.py:833–867  ·  view source on GitHub ↗
(base_stats: Stats, head_stats: Stats | None = None)

Source from the content-addressed store, hash-verified

831
832def pre_succ_pairs_section() -> Section:
833 def iter_pre_succ_pairs_tables(base_stats: Stats, head_stats: Stats | None = None):
834 assert head_stats is None
835
836 opcode_stats = base_stats.get_opcode_stats("opcode")
837
838 for opcode in opcode_stats.get_opcode_names():
839 predecessors = opcode_stats.get_predecessors(opcode)
840 successors = opcode_stats.get_successors(opcode)
841 predecessors_total = predecessors.total()
842 successors_total = successors.total()
843 if predecessors_total == 0 and successors_total == 0:
844 continue
845 pred_rows = [
846 (pred, Count(count), Ratio(count, predecessors_total))
847 for (pred, count) in predecessors.most_common(5)
848 ]
849 succ_rows = [
850 (succ, Count(count), Ratio(count, successors_total))
851 for (succ, count) in successors.most_common(5)
852 ]
853
854 yield Section(
855 opcode,
856 f"Successors and predecessors for {opcode}",
857 [
858 Table(
859 ("Predecessors", "Count:", "Percentage:"),
860 lambda *_: pred_rows, # type: ignore
861 ),
862 Table(
863 ("Successors", "Count:", "Percentage:"),
864 lambda *_: succ_rows, # type: ignore
865 ),
866 ],
867 )
868
869 return Section(
870 "Predecessor/Successor Pairs",

Callers

nothing calls this directly

Calls 10

CountClass · 0.85
get_opcode_statsMethod · 0.80
get_opcode_namesMethod · 0.80
get_predecessorsMethod · 0.80
get_successorsMethod · 0.80
totalMethod · 0.80
most_commonMethod · 0.80
RatioClass · 0.70
SectionClass · 0.70
TableClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…