Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def count(func_text, target_dict={}):
  2.     for f in dis.get_instructions(func_text):
  3.         if isinstance(f.argval, types.CodeType):
  4.             recursive_dict = count(f.argval, target_dict)
  5.             #print (recursive_dict)
  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.         else:
  12.             if f.opname in target_dict:
  13.                 target_dict[f.opname] += 1
  14.             else:
  15.                 target_dict[f.opname] = 1
  16.     return target_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement