[issue45338] Add key argument to collections.Counter

Dennis Sweeney report at bugs.python.org
Fri Oct 1 15:24:18 EDT 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

How is Counter(numbers, key=abs) any better than Counter(map(abs, numbers))?

It seems to me that "apply a function to each thing" (map) and "count the numbers of each thing" (Counter) are two orthogonal concepts, and there's no reason to entangle them. Their composition as "count the number of things with each function value" is probably better as a composition of two simple things rather than lumped together. I believe this is related to why PEP 455 was rejected.

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45338>
_______________________________________


More information about the Python-bugs-list mailing list