[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
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):
[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
> ..
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'