Why are there no ordered dictionaries?

Fuzzyman fuzzyman at gmail.com
Fri Nov 25 04:13:42 EST 2005


Alex Martelli wrote:
> 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.
>

If you slice an ordered dictionary, I assume you would expect to get an
ordered dictionary back ?

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

> 
> Alex




More information about the Python-list mailing list