Why are there no ordered dictionaries?

Alex Martelli aleax at mail.comcast.net
Wed Nov 23 11:24:40 EST 2005


Fuzzyman <fuzzyman at gmail.com> wrote:

> There is already an update method of course. :-)
> 
> Slicing an ordered dictionary is interesting - but how many people are
> actually going to use it ? (What's your use case)

I detest and abhor almost-sequences which can't be sliced (I consider
that a defect of collections.deque).  If the ordered dictionary records
by its sequencing the time order of key insertion, being able to ask for
"the last 5 keys entered" or "the first 3 keys entered" seem to me to be
perfectly natural use cases, and most naturally accomplished by slicing
of course, d[-5:] and d[:3] respectively.


Alex



More information about the Python-list mailing list