
Is that an invariant you expect to apply to other uses of the + operator?
py> x = -1 py> x <= (x + x) False
py> [999] <= ([1, 2, 3] + [999]) False
Please calm down. I meant each type implements "sum" in semantics of the type, in lossless way. What "lossless" means is changed by the semantics of the type.
-1 + -1 = -2 is sum in numerical semantics. There are no loss.
[1, 2, 3] + [999] = [1, 2, 3, 999] is (lossless) sum in sequence semantics.
So what about {"a": 1} + {"a": 2}. Is there (lossless) sum in dict semantics?
* {"a": 1} -- It seems {"a": 2} is lost in dict semantics. Should it really called "sum" ? * {"a": 2} -- It seems {"a": 1} is lost in dict semantics. Should it really called "sum" ? * {"a": 3} -- It seems bit curious compared with + of sequence, because [2]+[3] is not [5]. It looks like more Counter than container. * ValueError -- Hmm, it looks ugly to me.
So I don't think "sum" is not fit to dict semantics.
Regards,