A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-March/086670.html below:

[Python-Dev] PEP 372 -- Adding an ordered directory to collections ready for pronouncement

[Python-Dev] PEP 372 -- Adding an ordered directory to collections ready for pronouncementForest list8a.forest at tibit.com
Tue Mar 3 20:47:42 CET 2009
On Tue, March 3, 2009 11:20 am, Forest wrote:
> Okay, but I'd also like a convenient and fast way to find the oldest entry
> in an OrderedDict, which I think I'd need for an LRU cache.  Skimming the
> current patch (od7.diff), I didn't notice one.  Perhaps I simply missed
> something.  Shouldn't popitem() allow the caller to choose which end from
> which to pop?

Thinking it through a bit more, and LRU cache would actually need to
access the oldest item before knowing whether to remove it.  Besides,
popitem() should probably retain the signature of dict.popitem().  I
therefore retract my suggestion about popitem().

Still, I think an LRU cache would be a very common use case for an ordered
dict.  The current implementation already uses a list to keep track of
order, which makes accessing the oldest key a simple matter of exposing
it.  Perhaps a new method like getfirst() would be worth while here?

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4