Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. import time
  2.  
  3. def dec1(input_function):
  4.     def output_function(arg):
  5.         start = time.perf_counter()
  6.         input_function(arg)
  7.         end = time.perf_counter() - start
  8.         print(end)
  9.         return input_function(arg)
  10.     return output_function
  11.  
  12.  
  13.  
  14.  
  15. class SecondDecoratorTest():
  16.     to_do_inner = lambda a: a
  17.  
  18.     def to_do(self,a):
  19.         return self.to_do_inner(a)
  20.  
  21.  
  22. obj1 = SecondDecoratorTest()
  23. obj1.to_do_inner = lambda a: [i*i for i in a]
  24. result = obj1.to_do([1,2,3,4])
  25. print(result)
  26.  
  27. obj1.to_do = dec1(obj1.to_do)
  28.  
  29. result2 = obj1.to_do([1,2,3,4])
  30. print(result2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement