Decorators
A decorator is a function that takes a function and returns a new one, usually a wrapper that does something before or after calling the original.
@timed
def work(): ...
is just shorthand for work = timed(work).
The wrapper takes *args, **kwargs and passes them on, so the decorator works
on any function. It must also return the original's result, or the decorated
function will suddenly return None. That is the most common decorator bug.
Put @functools.wraps(func) on the wrapper. Without it, the decorated function
reports the wrapper's name and loses its docstring, which confuses tracebacks,
help, and debugging tools.
Interviewers often ask you to write a timing, logging, or caching decorator on the spot. Practise until it is automatic.
Run it, then remove @wraps(func) and look at what add.__name__ prints.