[Python-3000] ordered dict for p3k collections? (original) (raw)

Nicholas Bastin nick.bastin at gmail.com
Thu Sep 27 04:15:58 CEST 2007


On 9/26/07, Jason Orendorff <jason.orendorff at gmail.com> wrote:

One situation where a sorteddict would win is finding upper and lower bounds. This especially matters if you want to iterate over a specific range of keys: "show me all entries between 1 Jan 2007 and 1 Feb 2007" is O(N) in the number of entries in that range, not the entire data set.

Yeah, we do this a lot. We frequently end up with dictionaries with hundreds of thousands of entries and a simple wrapper on std::map gives us about 120x the performance of python dict in our use case, almost entirely due to the fact that we search a LOT more than we insert.

-- Nick



More information about the Python-3000 mailing list