[issue45936] collections.Counter drops key if value is 0 and updating using += operator

2021-11-29 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue45936] collections.Counter drops key if value is 0 and updating using += operator

2021-11-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think there is a need to list the inplace methods. They were put in to optimize what was already occurring when only the __add__ method was defined. Also, other container typically don't specifically call out the inplace methods. -- nosy

[issue45936] collections.Counter drops key if value is 0 and updating using += operator

2021-11-29 Thread Dennis Sweeney
Dennis Sweeney added the comment: This is consistent with the docstrings of the methods: - >>> help(Counter.__iadd__) Help on function __iadd__ in module collections: __iadd__(self, other) Inplace add from another counter

[issue45936] collections.Counter drops key if value is 0 and updating using += operator

2021-11-29 Thread Richard Decal
New submission from Richard Decal : In brief: ``` from collections import Counter x = Counter({'a': 0, 'b': 1}) x.update(x) # works: Counter({'a': 0, 'b': 2}) x += x # expected: Counter({'a': 0, 'b': 3}) actual: Counter({'b': 3}) ``` I expect `+=` and `.update()` to be synonymous. However, t