I’m having a hard time understanding the purpose of decorators and I think it’s because of the examples for use cases I’ve been given. I’m a noob on day 55 of a python course and the example I was given was for timing.
Suppose I have the functions:
fast_function() and slow_function() and I want to time them, the class suggests the use of decorators. But it seems simpler to create a function called time(function) with begin=time.time() function end=time.time() return end-begin.
Jake Weiler is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.