See here some decorator implementation examples in Python 3.6
-
line_profiler Profile the function line-by-line
-
require_login Exit the function depending on the return of another function
-
ensure_file Ensure the file exists, and if not create it
-
ensure_file2 Same as before, but more flexible
-
string_format Make sure that all string arguments passed to a function are formatted the same way
-
cached Cache the result of functions to reduce CPU time
-
timer Create a timer to track the time spent on the function call
-
profile_and_save Same as before, but maintaining a history in a
.json
file
Here are the results of the tests in the file end
call to large_function took 1.100401 seconds
call to large_function took 0.000000 seconds
a
b
d
ef
f
g