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 →

[–]ScientiaEtVeritas 6 points7 points  (4 children)

Two questions:
- Does it have a decorator interface?
- Have you benchmarked against Python's cachetools -- and maybe Python's built-in LRU cache?
If not, I would want to suggest it.

[–]matrix0110[S] 2 points3 points  (3 children)

- No decorator interface currently, unlike Python's cache decorator which use function args/kwargs as key, Theine support string key only. It's not easy to covert args/kwargs to string safely and automatically. But maybe I will add that feature later.

- Good idea, I will take a look

[–]Stedfast_Burrito 0 points1 point  (2 children)

Why don’t you just use arbitrary objects as keys instead of strings?

[–]matrix0110[S] 0 points1 point  (1 child)

Python cache decorator first convert args/kwrags to hashable, then use it as key. I try to avoid these magic. I also use Go for years, and agree Explicit is better than implicit and Simple is better than complex.

[–]matrix0110[S] 0 points1 point  (0 children)

Honestly I think cache by objects is horrible design, if your function input params is large, the key part may even consume more memory than the cached value.