Last active
January 5, 2024 16:23
-
-
Save Allwin12/8c96c1e502f562c8935ff07e0e5d63fb to your computer and use it in GitHub Desktop.
Decorator with args
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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