Python: How use use lru_cache with staticmethod
Date: 2020-04-27 | lru-cache | python | staticmethod |
DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)
problem
I'm trying to use lru_cache
with a staticmethod
function.
solution
To use lru_cache
with staticmethod
, you just have to make sure that lru_cache
is directly on top of the callable function.
Example:
@staticmethod
@lru_cache(maxsize=8)
async def a_static_method():
...
Want more like this?
The best way to support my work is to like / comment / share for the algorithm and subscribe for future updates.