diff options
-rw-r--r-- | Lib/collections.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index bd5d3e8..f255919 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -421,13 +421,15 @@ class Counter(dict): if iterable is not None: if isinstance(iterable, Mapping): if self: + self_get = self.get for elem, count in iterable.items(): - self[elem] += count + self[elem] = count + self_get(elem, 0) else: dict.update(self, iterable) # fast path when counter is empty else: + self_get = self.get for elem in iterable: - self[elem] += 1 + self[elem] = 1 + self_get(elem, 0) if kwds: self.update(kwds) |