LearnFrenzy
Sign in Take a free test

Recursion · Recursion MCQ · Question 13

lru_cache and list arguments Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links