Google


Tuesday, September 25, 2012

Python: combine lists or dictionaries

I have written some tests to see which approach is quickest to combine/reduce data where keys overlap. I tested whether it is better to store the data in lists or dictionaries. It turns out stacking lists and then using defaultdict (method 5) is the fastest. Using itertools.groupby() was the slowest.

The code is here http://pastebin.com/KM74xheZ


387299 1.15799999237 2.4681637353
387299 0.80999994278 2.4681637353
387299 0.805000066757 2.4681637353
387299 0.775000095367 2.4681637353
387299 0.677999973297 2.4681637353

No comments: