Function Decorator#
What Is a Decorated Function?#
The @
preceding a function is called a decorator. Such decoractor wraps a function and gives extra functionality without changing the original function.
The pattern is:
Example#
Use the @benchmark_timer
as function decorator to measure performance time:
Python | |
---|---|
Terminal output example: