Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count(func_text):
- target_dict = {}
- for f in dis.get_instructions(func_text):
- if isinstance(f.argval, types.CodeType):
- recursive_dict = count(f.argval)
- for key in recursive_dict:
- if key in target_dict:
- target_dict[key] += recursive_dict[key]
- else:
- target_dict[key] = recursive_dict[key]
- else:
- if f.opname in target_dict:
- target_dict[f.opname] += 1
- else:
- target_dict[f.opname] = 1
- return target_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement