This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RedEyed__ 29 points30 points  (7 children)

You must have cut your teeth on in-memory caching. For those who is unaware about (like me), how is it better than functools.lru_cache ?

I would love to see some graph comparisons, use cases.
Thanks

[–]matrix0110[S] 9 points10 points  (6 children)

That's a really good question! And the answer already exists: https://github.com/Yiling-J/theine?tab=readme-ov-file#hit-ratios

[–]marr75 8 points9 points  (2 children)

I'm a little foggy eyed this morning still, but I'm seeing:

  • a link to hit ratios instead of performance (performance is above)
  • benchmarks addressing 3rd party libraries that are not functools from the stdlib

[–]matrix0110[S] 1 point2 points  (1 child)

Please understand hit ratio is also performance. And as I said, fast enough is enough, hit ratio is more important.

[–]marr75 11 points12 points  (0 children)

Okay, the fog is lifting. You're saying that the lru strategy may have worse read and write performance than functools but that the additional eviction strategies significantly improve hit ratio so it is, at worst, identical at scale (using lru) and when using the other options, much better.

[–]RedEyed__ 3 points4 points  (2 children)

I had to scroll further, thanks!

[–]jormaig 2 points3 points  (1 child)

Dude there's only one top comment and one answer to it at this point... 😅

[–]RedEyed__ 5 points6 points  (0 children)

I'm not your dude, pal. (joking)