key = (instance, self.__class__)
try:
if key not in cache:
cache[key] = super().to_representation(instance)
return cache[key]
# key might not be hashable
except TypeError:
return super().to_representation(instance)
Python dict can use any hashable type for key
Object has 0 attachments
0 Comments