New submission from Richard Decal <richard.de...@gmail.com>:
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, the += operator is deleting keys if the source Counter has a zero count to begin with: ``` x = Counter({'a': 1}) x += Counter({'a': 0}) # ok: Counter({'a': 1}) y = Counter({'a': 0}) y += y # expected: Counter({'a': 0}) actual: Counter() ``` ---------- messages: 407348 nosy: crypdick priority: normal severity: normal status: open title: collections.Counter drops key if value is 0 and updating using += operator type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45936> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com