You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can this library be used in production code, does it save all the timing values. #51
I am wondering if the Time class stores all the timing values it receives. I was intrigued since median computation would require something like that. If it does store it, does that mean the data structure grows unbounded?
The Timers class is a class attribute of the Timer
It truly should not. It makes more sense for the global Timers to be a default; users should be allowed to pass their own Timers while instantiating the Timer instance.
Ideally Timers should be a factory such that all Timer objects created under it are bound by the factory's lifecycle. So in terms of object relationship, the API has it backwards.
Activity
mvanholsteijn commentedon Jan 6, 2025
TLDR; unless you explicitly call timer.timers.clear() it will grow unbounded.
https://github.com/realpython/codetiming/blob/main/codetiming/_timers.py#L24-L33
The Timers class is a class attribute of the Timer. It keeps a record of all starts and stops. So you need to clear it yourself every now and them.
dogganon commentedon Mar 9, 2026
It truly should not. It makes more sense for the global
Timers to be a default; users should be allowed to pass their ownTimerswhile instantiating theTimerinstance.Ideally
Timersshould be a factory such that allTimerobjects created under it are bound by the factory's lifecycle. So in terms of object relationship, the API has it backwards.@mvanholsteijn