[EMAIL PROTECTED] wrote:
Marc 'BlackJack' Rintsch:
counter['B'] = counter.get('B', 0) + 1

If you benchmark it, you will find that using the get() method it's
quite slower.

Slower than

if 'B' in counter:
>     counter['B'] += 1
> else:
>     counter['B'] = 1

?

It is not slower than defaultdict which I have compared to
>> counter['B'] = counter.get('B', 0) + 1
on a file with 125,000 additions default dict was significantly slower (only ~40seconds v ~30 secs for get) and used twice the memory.

--
djc
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to