mirror of
https://github.com/ARM-software/devlib.git
synced 2025-06-16 20:15:12 +01:00
memoized: further fixes; hash objects whre possible
This is further to commit 6d854fd4dc
Due to the way certain objects are handled, getting the frist few bytes
of an object may not be enough (e.g. strings do not store their values
inline). To further mitigate the issue, hash the object where possible.
This commit is contained in:
@ -33,6 +33,7 @@ import ctypes
|
||||
from operator import itemgetter
|
||||
from itertools import groupby
|
||||
from functools import partial
|
||||
from collections import Hashable
|
||||
|
||||
import wrapt
|
||||
|
||||
@ -557,6 +558,9 @@ def __get_memo_id(obj):
|
||||
ID string.
|
||||
"""
|
||||
obj_id = id(obj)
|
||||
if isinstance(obj, Hashable):
|
||||
return '{}/{}'.format(obj_id, hash(obj))
|
||||
else:
|
||||
obj_pyobj = ctypes.cast(obj_id, ctypes.py_object)
|
||||
# TODO: Note: there is still a possibility of a clash here. If Two
|
||||
# different objects get assigned the same ID, an are large and are
|
||||
|
Reference in New Issue
Block a user