Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > LRU cache (and other things missing from the standard library ...)

Reply
Thread Tools

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

 
 
Gerhard Haering
Guest
Posts: n/a
 
      11-01-2004
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)

iD8DBQFBhoTedIO4ozGCH14RAnfvAJ9bhKGHNf9zoK0NwzOFTu E+Is8Z3gCghTt6
sCNUY0zLg6C9V29PEw+sUFc=
=pJS6
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
Paul Moore
Guest
Posts: n/a
 
      11-04-2004
Gerhard Haering <> writes:

> 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.
--
One of the lessons of history is that nothing is often a good thing to
do and always a clever thing to say. -- Will Durant
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LRU cache? Paul Rubin Python 7 08-20-2007 12:10 PM
Design Patterns for LRU Cache in C++ Raja C++ 4 05-29-2007 04:31 PM
STL based LRU cache, any suggestions for improvements? pmouse@cogeco.ca C++ 0 05-01-2007 02:17 AM
Least recently used (LRU) memory question kkk C Programming 3 03-05-2007 08:19 AM
Least recently used (LRU) memory question kkk C Programming 0 03-04-2007 04:30 PM



Advertisments