Why are there no ordered dictionaries?

Christoph Zwerschke cito at online.de
Tue Nov 22 20:15:18 CET 2005


 >>def __init__(self, init_val = ()):
 >>     dict.__init__(self, init_val)
 >>     self.sequence = [x[0] for x in init_val]

Fuzzyman wrote:

 > But that doesn't allow you to create an ordered dict from another
 > ordered dict.

Right; I did not want to present a full implementation, just the 
relevant part. Of course, a real implementation should also allow to 
build an ordered dict from another ordered dict or an ordinary dict. (In 
the latter case, maybe the keys should be automatically sorted.) But one 
or two case disctinctions would not make things mentionable slower.

-- Christoph



More information about the Python-list mailing list