Basic usage
Input
add(1, 2)
Output
3
After decorating add with @timeit, calling add(1, 2) returns 3 and add.last_duration contains the execution time as a float.
Full lesson preview
Create a reusable decorator that measures a function's execution time and exposes it via a wrapper attribute.
Problem statement
Task
Examples
Input
add(1, 2)
Output
3
After decorating add with @timeit, calling add(1, 2) returns 3 and add.last_duration contains the execution time as a float.
Input format
Output format
Constraints
Samples
Input
add(4, 5)
Output
9
The decorated add returns the correct sum; timing is stored on add.last_duration (not printed).