Memoize.py (SCons-4.3.0) | : | Memoize.py (SCons-4.4.0) | ||
---|---|---|---|---|
skipping to change at line 162 | skipping to change at line 162 | |||
keys based on the method's input arguments. | keys based on the method's input arguments. | |||
A CountDict object is instantiated in a decorator for each of the | A CountDict object is instantiated in a decorator for each of the | |||
class's methods that memoizes its return value in a dictionary, | class's methods that memoizes its return value in a dictionary, | |||
indexed by some key that can be computed from one or more of | indexed by some key that can be computed from one or more of | |||
its input arguments. | its input arguments. | |||
""" | """ | |||
def __init__(self, cls_name, method_name, keymaker): | def __init__(self, cls_name, method_name, keymaker): | |||
""" | """ | |||
""" | """ | |||
Counter.__init__(self, cls_name, method_name) | super().__init__(cls_name, method_name) | |||
self.keymaker = keymaker | self.keymaker = keymaker | |||
def count(self, *args, **kw): | def count(self, *args, **kw): | |||
""" Counts whether the computed key value is already present | """ Counts whether the computed key value is already present | |||
in the memoization dictionary (a hit) or not (a miss). | in the memoization dictionary (a hit) or not (a miss). | |||
""" | """ | |||
obj = args[0] | obj = args[0] | |||
try: | try: | |||
memo_dict = obj._memo[self.method_name] | memo_dict = obj._memo[self.method_name] | |||
except KeyError: | except KeyError: | |||
self.miss = self.miss + 1 | self.miss = self.miss + 1 | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added |