Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

Python3 pass lists to function with functools.lru_cache

$
0
0

I want to cache a function that takes a list as a parameter, but when I try to do so with the functools.lru_cache decorator, it fails with TypeError: unhashable type: 'list'.

import functools@functools.lru_cache()def example_func(lst):    return sum(lst) + max(lst) + min(lst)print(example_func([1, 2]))

Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>