some kind of LFU dict...

Skip Montanaro skip at pobox.com
Fri Jan 28 15:09:46 EST 2005


    Joh> so i wondered if i can not use some kind of cache, i googled and
    Joh> found information on LRU, LFU, and LFU interested me : keep only
    Joh> most frequently used items inside dict (and memory) and writing
    Joh> others on disk for a possible future reuse.

I have a Cache class that you might subclass to provide different behavior:

    http://www.musi-cal.com/~skip/python/Cache.py

What it does now is throw out keys that match the desired criteria.  You
could subclass it to stuff those items in a DB file (probably using the
anydbm module) and read them from the DB file if an attempt to access a key
in the cache fails.

Skip




More information about the Python-list mailing list