Message 336812 - Python tracker (original) (raw)
- It is natural to expect the plus operator to be commutative, but this operation would necessarily be non-commutative.
In Python, the plus operator for sequences (strings, lists, tuples) is non-commutative.
But I have other arguments against it:
It conflicts with the plus operator of Counter (which is a specialized dict): Counter(a=2) + Counter(a=3) == Counter(a=5), but the proposed idea makes dict(a=2) + dict(a=3) == dict(a=3).
We already have a syntax for dict merging: {**d1, **d2}. It works with arbitrary mappings, in contrary to the plus operator, which needs a special support in argument types.