MCPcopy Create free account
hub / github.com/python/mypy / frequently_executed_blocks

Function frequently_executed_blocks

mypyc/analysis/blockfreq.py:15–32  ·  view source on GitHub ↗
(entry_point: BasicBlock)

Source from the content-addressed store, hash-verified

13
14
15def frequently_executed_blocks(entry_point: BasicBlock) -> set[BasicBlock]:
16 result: set[BasicBlock] = set()
17 worklist = [entry_point]
18 while worklist:
19 block = worklist.pop()
20 if block in result:
21 continue
22 result.add(block)
23 t = block.terminator
24 if isinstance(t, Goto):
25 worklist.append(t.label)
26 elif isinstance(t, Branch):
27 if t.rare or t.traceback_entry is not None:
28 worklist.append(t.false)
29 else:
30 worklist.append(t.true)
31 worklist.append(t.false)
32 return result

Callers 2

run_caseMethod · 0.90
generate_native_functionFunction · 0.90

Calls 5

setClass · 0.85
isinstanceFunction · 0.85
appendMethod · 0.80
popMethod · 0.45
addMethod · 0.45

Tested by 1

run_caseMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…