Re: Defaultdict and speed

2006-11-04 Thread Klaas
[EMAIL PROTECTED] wrote: > Klaas wrote: > > Benchmarks? > > There is one (fixed in a succesive post) in the original thread I was > referring to: > http://groups.google.com/group/it.comp.lang.python/browse_thread/thread/aff60c644969f9b/ > If you want I can give more of them (and a bit less silly, w

Re: Defaultdict and speed

2006-11-04 Thread bearophileHUGS
Klaas wrote: > Benchmarks? There is one (fixed in a succesive post) in the original thread I was referring to: http://groups.google.com/group/it.comp.lang.python/browse_thread/thread/aff60c644969f9b/ If you want I can give more of them (and a bit less silly, with strings too, etc). def ddict(n):

Re: Defaultdict and speed

2006-11-03 Thread Klaas
[EMAIL PROTECTED] wrote: > This post sums some things I have written in another Python newsgroup. > More than 40% of the times I use defaultdict like this, to count > things: > > >>> from collections import defaultdict as DD > >>> s = "abracadabra" > >>> d = DD(int) > >>> for c in s: d[c] += 1 > ..

Defaultdict and speed

2006-11-03 Thread bearophileHUGS
This post sums some things I have written in another Python newsgroup. More than 40% of the times I use defaultdict like this, to count things: >>> from collections import defaultdict as DD >>> s = "abracadabra" >>> d = DD(int) >>> for c in s: d[c] += 1 ... >>> d defaultdict(, {'a': 5, 'r': 2, 'b'