[Python-ideas] grouping / dict of lists
desmoulinmichel at gmail.com
Wed Jul 18 09:35:54 EDT 2018
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.barker at noaa.gov
> <mailto:chris.barker at noaa.gov>> wrote:
> On Fri, Jun 29, 2018 at 11:25 PM, Guido van Rossum <guido at python.org
> <mailto:guido at 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 at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas