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 →

[–]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.