[Python-ideas] grouping / dict of lists

Michael Selik mike at selik.org
Fri Jul 13 13:45:50 EDT 2018


On Mon, Jul 2, 2018 at 8:49 AM Chris Barker <chris.barker at noaa.gov> wrote:

> On Fri, Jun 29, 2018 at 11:25 PM, Guido van Rossum <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``.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180713/26991190/attachment.html>


More information about the Python-ideas mailing list