Skip to content

Commit cb91663

Browse files
Refactor performance decorator to set wrapper attributes
Removed the use of functools.wraps and manually set wrapper attributes.
1 parent c34acf3 commit cb91663

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎Week04/decorators_sinem_tanriver.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import time
22
import tracemalloc
3-
from functools import wraps
43

54

65
def performance(func):
7-
"""Measures time and memory of the decorated function and keeps statistics."""
8-
@wraps(func)
96
def wrapper(*args, **kwargs):
107
started_here = not tracemalloc.is_tracing()
118
if started_here:
@@ -22,9 +19,16 @@ def wrapper(*args, **kwargs):
2219
performance.total_time += elapsed
2320
performance.total_mem += peak
2421
return result
22+
23+
wrapper.__name__ = func.__name__
24+
wrapper.__doc__ = func.__doc__
2525
return wrapper
2626

2727

2828
performance.counter = 0
2929
performance.total_time = 0
3030
performance.total_mem = 0
31+
32+
performance.counter = 0
33+
performance.total_time = 0
34+
performance.total_mem = 0

0 commit comments

Comments
 (0)