LRU cache (and other things missing from the standard library ...)

  • Thread starter Gerhard Haering
  • Start date
G

Gerhard Haering

I recently implemented a LRU cache. And I wondered why such a useful class is
not already in the standard library. The only thing I found was a cookbook
entry but the comments said it was problematic.

Btw. my implementation is currently at
http://initd.org/svn/initd/pysqlite/trunk/misc/lru.py Does anybody see any
problems with this code?

I've already started translating it into C (*) , which speeds it up by between
factor 5 to 8. Maybe a candidate for the standard library once it's finished?

-- Gerhard

(*) http://initd.org/svn/initd/pysqlite/trunk/src/cache.c is the first iteration.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBhoTedIO4ozGCH14RAnfvAJ9bhKGHNf9zoK0NwzOFTuE+Is8Z3gCghTt6
sCNUY0zLg6C9V29PEw+sUFc=
=pJS6
-----END PGP SIGNATURE-----
 
P

Paul Moore

Gerhard Haering said:
I recently implemented a LRU cache. And I wondered why such a useful class is
not already in the standard library. The only thing I found was a cookbook
entry but the comments said it was problematic.
[...]

I've already started translating it into C (*) , which speeds it up by between
factor 5 to 8. Maybe a candidate for the standard library once it's finished?

Would this be a suitable addition for the collections module (which
currently only has deque in it)?

I'm not sure if a LRU cache counts as a "collection" in that sense. I
looked at the code briefly, but don't really follow it yet...

Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top