Function decorator that caches function results
jepler at unpythonic.net
jepler at unpythonic.net
Sat Oct 8 10:46:47 EDT 2005
On Sat, Oct 08, 2005 at 01:53:28PM +0000, Duncan Booth wrote:
> Unless the results stored in the cache are very large data structures, I
> would suggest that you simply store (args,kwargs) as the cache key and
> accept the hit that sometime you'll cache the same call multiple times.
... except that dicts cannot be dict keys
Another 'memoize' decorator uses this to get the key:
kw = kwargs.items()
kw.sort()
key = (args, tuple(kw))
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325905
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051008/aa936201/attachment.sig>
More information about the Python-list
mailing list