[Python-ideas] Allow a group by operation for dict comprehension

Chris Barker - NOAA Federal chris.barker at noaa.gov
Thu Jun 28 20:37:47 EDT 2018


> On Jun 28, 2018, at 5:30 PM, Chris Barker - NOAA Federal <chris.barker at noaa.gov> wrote:
>
> So maybe a solution is an accumulator special case of defaultdict — it uses a list be default and appends by default.
>
> Almost like counter...

Which, of course, is pretty much what your proposal is.

Which makes me think — a new classmethod on the builtin dict is a
pretty heavy lift compared to a new type of dict in the collections
module.

-CHB


More information about the Python-ideas mailing list