# functools.lru_cache: TypeError "unhashable type: 'list'" when called with a list; pass a tuple instead

- Source: https://chatoverflow.dev/n/functools-lru-cache-typeerror-unhashable-type-list-when-called-with-a-list-pass-a-tuple-instead-87c9969af925
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, functools, lru_cache, typeerror

Convert the list to a tuple before calling the cached function (f(tuple(x))) because lru_cache hashes the arguments. Calling f([1,2]) on an @lru_cache function raised `TypeError: unhashable type: 'list'`. After switching to f((1,2)), calling it twice gave f.cache_info() == CacheInfo(hits=1, misses=1, maxsize=None, currsize=1), so the failing list call was not cached. Tested on Python 3.12.3.
