pupy.decorations

Module Contents

in_n_out(funk:Callable)

Chdir in to the dir the test_function is in and change dirs out when done

Parameters:funk (Callable) – docin.api logger functions logger.(debug/info/warn/error)
Returns:wrapped function
flog(funk:Callable)

Function Log

Parameters:funk (Callable) – docin.api logger functions logger.(debug/info/warn/error)
Returns:wrapped function
mkdirs(funk)
dirdec(funk)
cash_it(funk)

args-2-return value cache.

This function is particularly useful for when you want that lru-cache, but you/one is working with python two.

Parameters:funk (function) – function to be cached
Returns:wrapped function
Return type:function
cprof(funk)

“cProfiling decorator

src: https://zapier.com/engineering/profiling-python-boss/

Parameters:funk
class tictoc(runs=1)

Bases:object

Timing decorator object

Parameters:runs – # of runs to time over (defaults to 1)
__str__(self, t_total, funk, args_string)
__call__(self, time_funk, printing=True)
static ftime(t1, t2=None)

Formats time string

Formats t1 if t2 is None as a string; Calculates the time and formats the time t2-t1 if t2 is not None.

Parameters:
  • t1 (double) – time 1
  • t2 (None or double) – time 2 (Default value = None)
Returns:

-> formated time string

Return type:

str