Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- def dec1(input_function):
- def output_function(arg):
- start = time.perf_counter()
- input_function(arg)
- end = time.perf_counter() - start
- print(end)
- return input_function(arg)
- return output_function
- class SecondDecoratorTest():
- to_do_inner = lambda a: a
- def to_do(self,a):
- return self.to_do_inner(a)
- obj1 = SecondDecoratorTest()
- obj1.to_do_inner = lambda a: [i*i for i in a]
- result = obj1.to_do([1,2,3,4])
- print(result)
- obj1.to_do = dec1(obj1.to_do)
- result2 = obj1.to_do([1,2,3,4])
- print(result2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement