[Python-Dev] caching in the stdlib? (was: New regex module for 3.2?)

Raymond Hettinger raymond.hettinger at gmail.com
Wed Jul 28 16:44:06 CEST 2010


On Jul 28, 2010, at 7:31 AM, Guido van Rossum wrote:

> On Tue, Jul 27, 2010 at 10:29 PM, Stefan Behnel <stefan_ml at behnel.de> 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.
> 
> The pattern we're talking about there is probably more something like
> memoization, so 'memo' or 'memoization' could b a reasonable module
> name. 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).


FWIW, this has been a popular caching/memoization recipe:
http://code.activestate.com/recipes/498245-lru-cache-decorator


Raymond



More information about the Python-Dev mailing list