[Python-ideas] ordered dict

Terry Reedy tjreedy at udel.edu
Tue May 1 06:08:07 CEST 2007


"BJörn Lindqvist" <bjourne at gmail.com> wrote 
in message 
news:740c3aec0704301624x60226147x7bb4c1def423441e at mail.gmail.com...

>Java, just like Python 3k will, forbids comparisions between disparate
>Comparable types. It follows that Java does not enforce any "total
>ordering" on disparate types either. The absence of a total ordering
>does not mean that Java's TreeMap class' constructor needs to be
>supplied with a list of "allowed key types" as you and Terry Reedy
>suggested that Python's hypothetical sorted dictionary would need.

I don't believe I said 'needs' and I already agreed that such a list would 
be less helpful than I had suggested.  But one would help give better 
messages from __str__ and exceptions.  Also, the first item added does not 
get compared to anything, so without such a list, it effectively determines 
the key type.

That said, propose what you want and see if it gets enough usage to justify 
addition to the collections module.  Anyone who wants a sorted dict with 
keytype attibute could get one by subclassing one without.

Terry Jan Reedy







More information about the Python-ideas mailing list