Decorators for Bioinformatics
@decorator above def f(): is exactly f = decorator(f) at definition time.
Core Pattern
import functools
def timer(func):
@functools.wraps(func) # preserves __name__, __doc__
def wrapper(*args, **kwargs):
import time
start = time.perf_counter()
result = func(*args, **kwargs)
print(f"[timer] {func.__name__}: {time.perf_counter() - start:.4f}s")
return result
return wrapper
@timer
def gc_co
[Description truncada. Veja o README completo no GitHub.]