Why are there no ordered dictionaries?

Rick Wotnaz desparn at wtf.com
Wed Nov 23 07:36:26 EST 2005


"Fuzzyman" <fuzzyman at gmail.com> wrote in
news:1132734447.104113.99140 at o13g2000cwo.googlegroups.com: 

> 
> Christoph Zwerschke wrote:
>> - the internal keys list should be hidden
> 
> I disagree. It is exposed so that you can manually change the
> order (e.g. to create a "sorted" dict, rather than one ordered
> by key insertion).
> 
> What do you *gain* by hiding it ?

The internal list should be 'hidden' in the sense that it itself 
would not be modifiable, though it should be routine to obtain a 
copy of it at any time. That copy could then be arranged as needed. 
Any rearrangement of the original list's order destroys the reason 
for having an entry- or change-ordered dict in the first place.

-- 
rzed



More information about the Python-list mailing list