Summing a 2D list

Karsten Heymann karsten.heymann at
Fri Jun 13 17:25:54 CEST 2008

Paddy <paddy3118 at> writes:
> How does your solution fare against the defaultdict solution of:
> d = collections.defaultdict(int)
> for u,s in zip(users,score): d[u] += s

list:         0.931s
dict + "in":  1.495s
defaultdict : 1.991s
dict + "if":  ~2s
dict + "try": ~4s

I've posted the (very rough) code to dpaste:


More information about the Python-list mailing list