• Home
  • Django
  • Python dict can use any hashable type for key

Python dict can use any hashable type for key

linkaiyi
Follow
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)
Object has 0 attachments

Was this article helpful?

This article is viewed 39 times!

Recent Viewed Articles

Related Articles

0 Comments

Leave a Comment

Support