On Tue, Mar 3, 2009 at 12:02 PM, Raymond Hettinger <pyt...@rcn.com> wrote: > > [Forest] >> >> 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? > > Forest, I've taken another look at what's involved and am inclined to > recommend the idea. It can be done without mucking-up the regular dict API > and without precluding any of the other possible underlying algorithms. I > like that it supports an entire new categoy of use cases with only a > trivial, easily-understood API extension. Patch is attached at > http://bugs.python.org/issue5397
-1. This seems creeping featurism -- it's easy enough to do this without adding a custom method. (And Forest admitted as much.) However, reviewing your patch made me realize that the list of keys is accessible as o._keys. I recommend that you either make this a __private variable (signalling strongly that people shouldn't ever reference it), or alternatively make it a public API. Otherwise, if you just leave it _undocumented, people *are* going to figure out clever things they can do with it (e.g. o._keys.sort() will turn the odict into a sorted dict). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com