sorteddict [was a PEP proposal, but isn't anymore!]

thebjorn BjornSteinarFjeldPettersen at gmail.com
Sat Sep 29 11:11:36 EDT 2007


On Sep 29, 4:23 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
[...]
> Another example would be if you had a library which serialised a dictionary
> to xml. There is nothing wrong with the library if it doesn't care about
> order, but if you have some other reason why you want the xml to be stable
> (e.g. because you store it in a version control system and want to compare
> revisions) then a sorteddict would allow you to impose that behaviour on
> the library from outside.
>
> Contrary to my earlier insistence that sorteddict is only really useful if
> you can have a key parameter, both of these examples simply want an
> arbitrary but defined order of iteration for dictionary keys. A much
> simpler sorteddict that has been discussed earlier would be sufficient.

In fact, a dictionary that maintains insertion order would work in
this case too.

-- bjorn




More information about the Python-list mailing list