Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on PEP 572: Python assignment expressions has been accepted. Parent comment
collections.Counter is what you want for the counting case.
dict.get() + dict.setdefault() for the general case.
defaultdict is only useful if the factory is expensive to call.
There are no comments on this comment yet.
collections.Counter is what you want for the counting case.
dict.get() + dict.setdefault() for the general case.
defaultdict is only useful if the factory is expensive to call.