https://github.com/python/cpython/commit/e667f262a186621183ce81a34d62ae63c09667de commit: e667f262a186621183ce81a34d62ae63c09667de branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity <[email protected]> date: 2026-07-27T22:30:27-04:00 summary:
[3.13] gh-154746: Update docstring for `collections.Counter` (GH-154792) (GH-154795) Added a note to `collections.Counter`'s docstring that initializing a `Counter` from a `Mapping` or `Counter` will have different behaviour than initializing from other `Iterable`s. This behaviour was already documented in the canonical docs but is missing from the help() output. (cherry picked from commit 22a123f1305bf45d5d35441e9164fb4528da493c) Co-authored-by: Dan Shernicoff <[email protected]> files: M Lib/collections/__init__.py diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index e5a280e1949de90..614e0d4db102cbb 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -550,6 +550,9 @@ class Counter(dict): or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. + When constructed from a Mapping or Counter, the original object's + values will be used as the initial counts. + >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
