From: Dan Shernicoff Date: Tue, 28 Jul 2026 01:41:17 +0000 (-0400) Subject: gh-154746: Update docstring for `collections.Counter` (GH-154792) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22a123f1305bf45d5d35441e9164fb4528da493c;p=thirdparty%2FPython%2Fcpython.git gh-154746: Update docstring for `collections.Counter` (GH-154792) 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. --- diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py index 20f1e728733f..5dbcac19e7a9 100644 --- a/Lib/collections/__init__.py +++ b/Lib/collections/__init__.py @@ -553,6 +553,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