Question 13
Back to Exercise
Why does a function decorated with @lru_cache fail when called with a list?
- A lru_cache only works with ints
- B Lists are too large to cache
- C The cache uses the arguments as dict keys, and lists are unhashable Correct
- D It does not fail
Correct Answer: Option C
The call raises TypeError: unhashable type: 'list'. Pass a tuple instead.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!