mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 05:30:44 +00:00
utils/misc: memoized: fix kwarg IDs
Use __get_memo_id() for keyword arguments, rather than stringifying them. The has somewhat lower chance of producing the same identifier for two conceptually unequal objects.
This commit is contained in:
parent
a3c04fc140
commit
bdaea26f6f
@ -661,7 +661,7 @@ def memoized(wrapped, instance, args, kwargs): # pylint: disable=unused-argumen
|
|||||||
|
|
||||||
def memoize_wrapper(*args, **kwargs):
|
def memoize_wrapper(*args, **kwargs):
|
||||||
id_string = func_id + ','.join([__get_memo_id(a) for a in args])
|
id_string = func_id + ','.join([__get_memo_id(a) for a in args])
|
||||||
id_string += ','.join('{}={}'.format(k, v)
|
id_string += ','.join('{}={}'.format(k, __get_memo_id(v))
|
||||||
for k, v in kwargs.items())
|
for k, v in kwargs.items())
|
||||||
if id_string not in __memo_cache:
|
if id_string not in __memo_cache:
|
||||||
__memo_cache[id_string] = wrapped(*args, **kwargs)
|
__memo_cache[id_string] = wrapped(*args, **kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user