should python have a sort list-map object in the std-lib?

Tim Henderson tim.tadh at gmail.com
Sun Nov 27 23:35:03 EST 2005


Hi

The question why are there no sorted dictionaries in python, seems to
pop up with unseeming regularity. That question in itself in
nonsensical sense dictionaries are hash-maps, however should python
have a sorted map type object is a good question.

clearly many people like have a sorted map, and sorting the keys every
time seems rather wasteful, as does keeping a separate sorted list of
the keys.

a related question is, in python is it more efficient to a maintain a
list type in sorted order by inserting each new object in the correct
location (by say finding it with a binary search and then using del
list[x]) or appending each new item to the end of said list and using
the built-in .sort method, or sorted() function?
--
Tim Henderson
mail me: tim.tadh at gmail.com



More information about the Python-list mailing list