[Python-3000] ordered dict for p3k collections?

Arvind Singh arvind1.singh at gmail.com
Sun Sep 16 16:45:40 CEST 2007


> How do you get from "some keys can't be ordered" to "it doesn't make
> sense for Python to have sorteddict or sortedset"?  If you want to use
> keys that can't be ordered, then feel free to continue to use dict.
> For situations in which ordering is important, that language should
> support that.  When did this become an all or nothing proposition?
> There's plenty of space for both dict and sorteddict.


Sorry for premature conclusions. All I wanted to do was remind the potential
problems with any "generic" implementation.

And I did say, when ordering is important, we are left with two choices:
1) Sort explicitly (whenever required) and be prepared to handle exceptions
raised during sort operation.
2) Have a implicitly "sorted" implementation and handle exceptions at every
insertion.

I, personally, tend to prefer the former solution. Later case is useful when
we have large objects and we do large number of insertions, in which case,
per insertion exception handling would be inefficient. Former case, in turn,
can be slightly confusing and a bit to debug.

-- 
Regards,
Arvind
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20070916/cf740b8b/attachment.htm 


More information about the Python-3000 mailing list