AA
Size: a a a
AA
S
AA
AA
S
def log_time(func):
now = time.now()
result = func()
print(time.now() - now)
return result
def my_func(*args, **kwgs):
def _my_func():
do_some_shit(*args, **kwgs)
return log_time(_my_func)
V
S
V
S
S
S
V
AA
def log_time(func):
now = time.now()
result = func()
print(time.now() - now)
return result
def my_func(*args, **kwgs):
def _my_func():
do_some_shit(*args, **kwgs)
return log_time(_my_func)
S
import functools
def log_time(f):
@functools.wraps(f)
def w(*args, **kwgs):
now = time.now()
r = f(*args, **kwgs)
print(time.now() - now)
return r
return w
def my_func():
do_some_shit()
my_func = log_time(my_func) # то что делает декоратор под капотом @log_time
const logTime = (f) => {
const w = function () {
const now = new Date();
const r = f.apply(null, arguments);
console.log(new Date() - now);
return r;
};
return w;
};
const myFunc = logTime(() => {
doSomeShit();
});
AA
S
S
S
V
S
sphinx-doc
, даже если используется wraps
. Он не может прочитать из-под декоратора имя функции и аргументы, и похоже что даже по прошествии 4 лет эта проблема еще актуальна.