[Python-ideas] Dict joining using + and +=
INADA Naoki
songofacandy at gmail.com
Fri Mar 1 10:56:41 EST 2019
>
> OK, thanks for explaining! So more formally speaking, you want to say that for other examples of '+' in Python
> x1 + y == x2 + y if and only if x1 == x2, while for the proposed '+' for dicts there may be many different x_i such that
> x_i + y gives the same result.
>
It's bit different thank my mind. I'm OK to violate " x1 + y == x2 +
y if and only if x1 == x2", if it's not
important for semantics of type of x1, x2, and y.
Mapping is defined by key: value pairs. It's core part. I don't want
to call operator losts key: value pair as "sum".
That's why I thought this proposal is more serious abuse of + operator.
By the way, in case of sequence, `len(a) + len(b) == len(a + b)`. In
case of set, `len(a) + len(b) >= len(a | b)`.
Proposed operation looks similar to `set | set` than `seq + seq` in
this point of view.
I don't propose | than +. I just mean difference between
dict.update() and seq+seq is not
smaller than difference between dict.update() and set|set.
If | seems not fit to this operation, + seems not fit to this operation too.
--
INADA Naoki <songofacandy at gmail.com>
More information about the Python-ideas
mailing list