Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. def count(func_text):
  2.     target_dict = {}
  3.     for f in dis.get_instructions(func_text):
  4.         if isinstance(f.argval, types.CodeType):
  5.             recursive_dict = count(f.argval)
  6.             for key in recursive_dict:
  7.                 if key in target_dict:
  8.                     target_dict[key] += recursive_dict[key]
  9.                 else:
  10.                     target_dict[key] = recursive_dict[key]
  11.                    
  12.         else:
  13.             if f.opname in target_dict:
  14.                 target_dict[f.opname] += 1
  15.             else:
  16.                 target_dict[f.opname] = 1
  17.     return target_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement