I think this is better suited for python-ideas, so moving it there.

Guido van Rossum, 28.07.2010 16:31:
On Tue, Jul 27, 2010 at 10:29 PM, Stefan Behnel  wrote:
What about actually putting it visibly into the stdlib? Except for files, I
didn't see much about caching there, which seems like a missing battery to
me. Why not do it as with the collections module and add stuff as it comes
in?

Caching is a rather large topic to focus on in a single stdlib module
or package. It means radically different things to different people.

Sure. All I would like to see in the stdlib is a dict based cache with a bounded size and a set of different policies that keep it at that size.

Maybe a BoundedDict would match that need.


The pattern we're talking about there is probably more something like
memoization, so 'memo' or 'memoization' could b a reasonable module
name.

That would be a second interface to it, I'd say. The normal interface would just be the regular mapping interface, maybe even just a .get() method instead of a KeyError raising lookup.


Maybe it could provide a decorator that you configure with
things like how many entries max, the expiration policy (or different
policies could have different decorators), and how to compute the memo
key from the arguments to the function (the default could be the
repr() of the argument tuple).

Absolutely.

Stefan

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to