[Python-ideas] ordered dict
Josiah Carlson
jcarlson at uci.edu
Sat Apr 21 20:29:44 CEST 2007
"BJörn Lindqvist" <bjourne at gmail.com> wrote:
> On 4/21/07, Terry Reedy <tjreedy at udel.edu> wrote:
> > But it *is* currently a problem for lists that will become much more
> > extensive in the future, so it *is* currently a problem for sorted dicts
> > that will be much more of a problem in the future. Hence, sorted dicts
> > will have to be restricted to one type or one group of truly comparable
> > types.
>
> Alternatively, you could require a comparator function to be specified
> at creation time.
You could, but that would imply a total ordering on elements that Python
itself is removing because it doesn't make any sense. Including a list
of 'acceptable' classes as Terry has suggested would work, but would
generally be superfluous. The moment a user first added an object to
the sorted dictionary is the moment the type of objects that can be
inserted is easily limited (hello Abstract Base Classes PEP!)
- Josiah
More information about the Python-ideas
mailing list