fix list bug

This commit is contained in:
fx_kirin
2020-01-08 13:20:55 +09:00
parent c8b81b9e9a
commit c55ac3a07f
+8 -7
View File
@@ -152,10 +152,10 @@ class _PickleCore(_BaseCore):
return key, self._get_cache().get(key, None)
def get_entry(self, args, kwds):
key = tuple(self.hash_args(key) for key in args + tuple(sorted(kwds.items())))
key = tuple(self._hash_args(key) for key in args + tuple(sorted(kwds.items())))
return self.get_entry_by_key(key)
def hash_args(self, value):
def _hash_args(self, value):
try:
import pandas
if isinstance(value, pandas.DataFrame):
@@ -165,15 +165,16 @@ class _PickleCore(_BaseCore):
if hasattr(value, "tobytes"): # For numpy
return hash(value.tobytes())
if hasattr(value, "__iter__"): # For iterators
hash_array = []
for elem in value:
hash_array.append(value)
return tuple(hash_array)
if isinstance(value, (list, tuple)):
hash_array = []
for elem in value:
hash_array.append(self._hash_args(elem))
return tuple(hash_array)
if hasattr(value, "items"): # For dict
hash_array = []
for key, elem in value.items:
hash_array.append(key)
hash_array.append(elem)
hash_array.append(self._hash_args(elem))
return tuple(hash_array)
return hash(value)