A High Order Timer Function

Photo by JJ Ying on Unsplash

A high order function is a function that takes a function as an argument or returns a function.
One use case is when you want to do something more with your function without altering the passed-on function.

For example, if we want to time the execution of a function the not optimal way.

It’s not optimal! What if you want to perform the same task on another function.

The High order function approach, passing the function cubeit to our timer function.

Well, this is cluttered! is there a neat way to achieve the same result?

Yes, the pythonic way of using decorators.

Note that @timer_fun is equivalent to timer_fun(cubeit).
So, what else can I do with decorators, logging to an external file!

Programming and Statistics for now!