Python: How use use lru_cache with staticmethod

Date: 2020-04-27 | python | lru-cache | staticmethod |

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 / easiest way to support my work is by subscribing for future updates and sharing with your network.