1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +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:
Sergei Trofimov 2018-11-14 13:38:55 +00:00 committed by Marc Bonnici
parent a3c04fc140
commit bdaea26f6f

View File

@ -661,7 +661,7 @@ def memoized(wrapped, instance, args, kwargs): # pylint: disable=unused-argumen
def memoize_wrapper(*args, **kwargs):
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())
if id_string not in __memo_cache:
__memo_cache[id_string] = wrapped(*args, **kwargs)