Non-essential attributes, such as mode, mean, etc., should only be determined on user request, rather than for every time the values would change. Especially important for attributes that require computation, such as numerical approximation of statistics.
Search internet for "caching", See functools!!
Suggested improvement:
Update methods reset dependent attributes to None
Property getters trigger on None to perform the relevant computation
Implement check in Base classes, call "set_stat" subclass methods to do computation
Use NaN instead of None?
See random.elements.Mixture.mode treatment for an example
Non-essential attributes, such as
mode
,mean
, etc., should only be determined on user request, rather than for every time the values would change. Especially important for attributes that require computation, such as numerical approximation of statistics.Search internet for "caching", See
functools
!!Suggested improvement:
Update methods reset dependent attributes to
None
Property getters trigger on
None
to perform the relevant computationUse NaN instead of None?
See
random.elements.Mixture.mode
treatment for an example