@@ -1415,13 +1415,13 @@ def get_filename():
14151415 return f ' profile- { time_str} .png '
14161416```
14171417
1418- #### Decorator for timing functions:
1418+ ### Timing Decorators
1419+ #### Prints runtime of decorated function:
14191420``` python
14201421from timeit import default_timer
14211422from datetime import timedelta
14221423
14231424def stopwatch (func ):
1424- """ Prints runtime of decorated function."""
14251425 def out (* args , ** kwargs ):
14261426 start = default_timer()
14271427 result = func(* args, ** kwargs)
@@ -1431,13 +1431,12 @@ def stopwatch(func):
14311431 return out
14321432```
14331433
1434- #### Decorator for profiling functions :
1434+ #### Saves run call profile of the decorated function to file :
14351435``` python
14361436from cProfile import Profile
14371437from pstats import Stats
14381438
14391439def profiler (func ):
1440- """ Saves run call profile of the decorated function to file."""
14411440 def out (* args , ** kwargs ):
14421441 profile = Profile()
14431442 result = profile.runcall(func, * args, ** kwargs)
@@ -1451,10 +1450,9 @@ def profiler(func):
14511450 return out
14521451```
14531452
1454- #### Decorator for function tracing :
1453+ #### Prints arguments and output of a decorated function :
14551454``` python
14561455def tracer (func ):
1457- """ Prints arguments and output of a decorated function."""
14581456 def out (* args , ** kwargs ):
14591457 result = func(* args, ** kwargs)
14601458 arg_list = [repr (x) for x in args]
0 commit comments