sorteddict PEP proposal [started off as orderedict]

Andrew Durdin adurdin at gmail.com
Tue Sep 25 06:13:10 EDT 2007


On 9/25/07, Mark Summerfield <m.n.summerfield at googlemail.com> wrote:
>
>     Since the sorteddict's data is always kept in key order, indexes
>     (integer offsets) into the sorteddict make sense.  Five additional
>     methods are proposed to take advantage of this:
>
>     key(index : int) -> value
>
>     item(index : int) -> (key, value)
>
>     value(index : int) -> key
>
>     set_value(index : int, value)
>
>     delete(index : int)

But what about using non-sequential integer keys (something I do quite often)?

e.g. sorteddict({1:'a', 3:'b': 5:'c', 99:'d'})[3]  should return 'b', not 'd'.

Andrew



More information about the Python-list mailing list