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

Function count_instr_recursively

Lib/test/test_peepholer.py:32–42  ·  view source on GitHub ↗
(f, opname)

Source from the content-addressed store, hash-verified

30
31
32def count_instr_recursively(f, opname):
33 count = 0
34 for instr in dis.get_instructions(f):
35 if instr.opname == opname:
36 count += 1
37 if hasattr(f, '__code__'):
38 f = f.__code__
39 for c in f.co_consts:
40 if hasattr(c, 'co_code'):
41 count += count_instr_recursively(c, opname)
42 return count
43
44
45def get_binop_argval(arg):

Calls 1

get_instructionsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…