Simple lru cache?

Steve Holden sholden at holdenweb.com
Fri Oct 4 18:30:53 EDT 2002


"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m3elb5etuk.fsf at mira.informatik.hu-berlin.de...
> "Steve Holden" <sholden at holdenweb.com> writes:
>
> > What, you mean like
> >
> >     mylst = mylst[:n] + mylst[n+1:] + [mylst[n]]
> >
> > for example?
>
> I think Ype will critize this solution for its O(m) complexity, where
> m is the number of elements in the cache.
>

Well, the order of the behavior wasn't metnioned in the question, but I
would quite understand if he felt it wasn't a good idea to reconstruct the
whole list that way.

The fact is that an LRU cache is far from simple!

regards
-----------------------------------------------------------------------
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/
Previous .sig file retired to                    www.homeforoldsigs.com
-----------------------------------------------------------------------






More information about the Python-list mailing list