import time
import functools
from typing import Callable

def timer(func: Callable) -> Callable:
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        start = time.perf_counter()
        result = func(*args, **kwargs)
        end = time.perf_counter()
        print(f"[Lanyora] ⏱️ {func.__name__} executed in {end-start:.4f}s")
        return result
    return wrapper

def retry(attempts: int = 3, delay: float = 1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for i in range(attempts):
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    if i == attempts-1:
                        raise e
                    time.sleep(delay)
        return wrapper
    return decorator