3 ms·
If you want other than LRU or time-to-expire then I take your point, but those are IME the most common types, therefore support it. The cache in python's functo
by zasdffaa 4y ago
If you want other than LRU or time-to-expire then I take your point, but those are IME the most common types, therefore support it. The cache in python's functools are default 128 items, LRU (from memory).
If you really want specialised caching policy then you can have that as an extra object/function passed in to the cache (edit: a predicate or predicate closure), but I've never needed it. LRU all the way for me and most others.
> Just look at common Python libraries (even the standard library itself) and count how many times they use @memoize anywhere.
Obviously! They are general purpose so they can't make any guess, and if they need caching that's up to the user, who can then add @functools.memoize in one line. That's what it's there for!
> And that fact is not widespread is not due to lack of knowledge of the technique.
IME it very much is.
> Notice this is the same reason why you don't see a general-purpose "tree" or "graph" class in many languages' standard libraries
But then caching is far simpler than graphs, and anyway from your link: "(Out of more than a dozen projects in various domains I have been involved in so far, I recount two which actually needed graphs.) So I guess there was no really big pressure from the Java community in general to have a Graph in the Collection Framework."