What's the best way to implement python cache for better performance? or How does python cache work a

18 Replies, 1742 Views

Honestly, python cache is overused sometimes. Like, if your function runs in 0.001s, caching might just add overhead.

But for stuff like API calls or DB queries? Absolute lifesaver. Just remember to set a `maxsize` in `lru_cache` or you’ll leak memory.

Pro tip: Use `@lru_cache(maxsize=None)` sparingly. It’s a one-way ticket to OOM errors if you’re not careful.

Messages In This Thread



Users browsing this thread: 1 Guest(s)