An ordered dictionary for the Python library?

James Stroud jstroud at mbi.ucla.edu
Thu Sep 13 22:21:08 EDT 2007


Carl Banks wrote:
> On Sep 13, 4:20 pm, James Stroud <jstr... at mbi.ucla.edu> wrote:
>> Mark Summerfield wrote:
>>> - If an item is inserted it is put in the right place (because the
>>> underlying data structure, b*tree, skiplist or whatever is
>>> intrinsically ordered by < on the key)
>> +1 for all your suggestions below, but -1 for the above. You suggest that
>>
>>    myOrderedDict['key'] = value
>>
>> would place it in the dictionary in sorted order depending on 'key'.
>> More natural to some of us (or maybe its just me) would be to append the
>> key/value pair to the end of items.
> 
> Or, maybe, like, you know, you could have two different types that
> maintain two different orders?
> 

Do you mean, like, a SortedDict and an OrderedDict like I mentioned in 
the post you are replying to?



More information about the Python-list mailing list