An ordered dictionary for the Python library?

stef s.mientki at id.umcn.nl
Wed Sep 12 03:51:02 EDT 2007


Mark Summerfield wrote:
> I feel that Python lacks one useful data structure: an ordered
> dictionary.
>
> I find such data structures v. useful in C++. I know that in Python
> the sort function is v. fast, but often I prefer never to sort but
> simply to use an ordered data structure in the first place.
> (I'm aware that for ordered lists I can use the bisect module, but I
> want an ordered key-value data structure.)
>
> I think other people must find such things useful. There are three
> implementations on the Python Cookbook site, and one on PyPI, all in
> pure Python (plus I have my own implementation, also pure Python).
>
> I would suppose that it would be better if it was implemented in C---
> for example, my own pure Python ordered dict loads data about eight
> times slower than the built-in dict. Nonetheless, I still find it
> worth using for the convenience it offers.
>
> Do other Python programmers feel this lack? Is this worth a PEP?
>
>   
Yes I think it's really useful,
(or at least I'm used to it in other languages ;-)
If you're going to extend the dictionary,
there's one other flag I'm continuously missing:
"case-insensitive" key.

cheers,
Stef Mientki

> [I originally asked about this on the P3K mailing list, but then
> realised that it isn't version-specific really.]
>
>   



More information about the Python-list mailing list