Re: Optimize a cache

2005-06-23 Thread Tim Williams
- Original Message - From: Florian Lindner [EMAIL PROTECTED] Hello, I am building a object cache in python, The cache has a maximum size and the items have expiration dates. At the moment I'm doing like that: What possible you see to optimize this lookup? Or anything else you see

Optimize a cache

2005-06-22 Thread Florian Lindner
Hello, I am building a object cache in python, The cache has a maximum size and the items have expiration dates. At the moment I'm doing like that: cache = {} # create dictionary cache[ID] = (object, timestamp) # Save a tuple with the object itself and a timestamp (from datetime.datetime.now())

Re: Optimize a cache

2005-06-22 Thread Paul Rubin
Florian Lindner [EMAIL PROTECTED] writes: What possible you see to optimize this lookup? Or anything else you see to make it better? Use the heapq module. -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimize a cache

2005-06-22 Thread gene tani
i think ring buffer http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68429 -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimize a cache

2005-06-22 Thread Paul Rubin
Florian Lindner [EMAIL PROTECTED] writes: What possible you see to optimize this lookup? Or anything else you see to make it better? Do you need to update the timestamp of cached entries when you access them? If yes, use the heapq module. If no, is the cache something different from a simple

Re: Optimize a cache

2005-06-22 Thread gene tani
a ring buffer? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68429 -- http://mail.python.org/mailman/listinfo/python-list