Code Bash!!! (CacheDictionary)

Gustavo Cordova gcordova at hebmex.com
Wed Mar 6 19:24:14 EST 2002


Howdy everyone.

I've been tinkering aimlessly for a few days; the miniXML module
is sitting in the backburner for now, I'm trying to design a way
for it to request more text ("Feed Me Seymour!!") without it
breaking the current simple, toyish design, and at the same time,
having the parser "not notice" that new text has been inserted.

Anyhow, I subclassed the "dict" class, to make one with some
cache functionality, such as item timeouts, automatic purging
of old elements, and maximum length / LSU dropping.

So here's an afternoon of tinkering, for your enjoyment. It's
quite simple, and running the script without any parameters
runs a few tests on it.

The class can be subclassed, so your program can catch when
an item is being dropped either because it's the oldest and the
LRU catcher got it, or because it's being dropped along with
all the other timed-out items.

Have a nice evening!

pd: man, python's cool. :-)
-- 
Gustavo Córdova Avila
> gcordova at sismex.com
Å 8351-3861 | 8351-3862

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CacheDictionary.py
Type: application/octet-stream
Size: 5678 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020306/d24bc357/attachment.obj>


More information about the Python-list mailing list