Counter also consider any missing key has the value "0". With the constructor (accepting any iterable) and the most_common(n), it's just a very set of features if you need to count anything.
Le 13/07/2018 à 19:45, Michael Selik a écrit : > On Mon, Jul 2, 2018 at 8:49 AM Chris Barker <chris.bar...@noaa.gov > <mailto:chris.bar...@noaa.gov>> wrote: > > On Fri, Jun 29, 2018 at 11:25 PM, Guido van Rossum <gu...@python.org > <mailto:gu...@python.org>> wrote: > > > Hm, this actually feels heavier to me. But then again I never > liked or understood the need for Counter -- > > > actually, me neither -- and partly because it's too lightweight -- > that is, it's still a regular dict, and you pretty much have to know > that to use it. That it, it provides a nice counting constructor, > but after that, it's just a key:integer dict :-) > > > Counter provides ``most_common`` which is often implemented > inefficiently if written from scratch. People mistakenly use ``sorted`` > instead of ``heapq.nlargest``. > > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/