Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Last active January 5, 2024 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/8c96c1e502f562c8935ff07e0e5d63fb to your computer and use it in GitHub Desktop.
Save Allwin12/8c96c1e502f562c8935ff07e0e5d63fb to your computer and use it in GitHub Desktop.
Decorator with args
import time
from functools import wraps
def timer(func):
@wraps(func)
def wrapper(*args, **kwargs):
start = time.time()
result = func(*args, **kwargs)
end = time.time()
print(f"Execution time of {func.__name__}: {end - start} seconds")
return result
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment