This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Avoid inadvertently special casing Counter in statistics module
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steven.daprano Nosy List: gregory.p.smith, larry, ncoghlan, oscarbenjamin, python-dev, steven.daprano, wolma
Priority: release blocker Keywords: patch

Created on 2014-02-02 01:16 by ncoghlan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
counter.patch steven.daprano, 2014-02-07 21:37
Messages (5)
msg209930 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-02-02 01:16
As per the python-ideas thread at the statistics.mode() function currently passes its argument directly to the collections.Counter() constructor. This results in Counter() objects being special-cased rather than treated as ordinary iterables.

For the main API, it seems more appropriate to force treatment as an iterable by calling iter() on the argument before passing it to the Counter() constructor.

I'll file a separate RFE about making it easier and more efficient to use the statistics module with weight/frequency mappings.
msg209932 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-02-02 01:22
Issue 20479 covers providing tools for efficiently working with weight/frequency mappings in 3.5 (and presumably the statslib PyPI module)
msg210564 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2014-02-07 21:37
Fix as suggested by Nick, and new test.
msg210601 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-02-08 09:44
New changeset 78d0b7472697 by Nick Coghlan in branch 'default':
Issue #20478: avoid special casing Counter in statistics
msg210602 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-02-08 09:47
Committed on your behalf Steven, since I'm still not sure if your SSH key has been registered yet.
Date User Action Args
2022-04-11 14:57:57adminsetgithub: 64677
2014-02-08 09:47:29ncoghlansetstatus: open -> closed
resolution: fixed
messages: + msg210602

stage: test needed -> resolved
2014-02-08 09:44:48python-devsetnosy: + python-dev
messages: + msg210601
2014-02-07 21:37:29steven.dapranosetfiles: + counter.patch
keywords: + patch
messages: + msg210564
2014-02-02 11:57:25steven.dapranosetassignee: steven.daprano
2014-02-02 01:22:52ncoghlanlinkissue20479 dependencies
2014-02-02 01:22:13ncoghlansetmessages: + msg209932
2014-02-02 01:16:29ncoghlancreate