Message362813
> Note that in your last message, `d1 |= cm2` will fail for this reason. You can of course fix that with `d1 |= dict(cm2)`, although IIUC there's no reason one of the maps couldn't be some other [Mutable]Mapping.
Mappings and iterables are fine for the in-place variant. :)
>>> from collections import ChainMap
>>> d = {}
>>> c = ChainMap({"r": 2, "d":2})
>>> d |= c
>>> d
{'r': 2, 'd': 2}
I think it would be confusing to have `ChainMap | ChainMap` behave subtly different than `dict | ChainMap`. It would be *especially* odd if it also differed subtly from `ChainMap | dict`.
To recap:
+1 on adding the operators with dict semantics,
+0 on no PEP 584 for ChainMap.
-0 on implementing them, but changing the winning behavior by concatenating the maps lists or something. This would probably make more sense to me as a `+` operator, honestly. :(
-1 for having the operators behave differently (other than performance shortcuts) for `cm | d`, `cm | cm`, `cm |= d`, `cm |= cm`. |
|
Date |
User |
Action |
Args |
2020-02-27 15:57:52 | brandtbucher | set | recipients:
+ brandtbucher, gvanrossum, rhettinger, mark.dickinson, scoder, serhiy.storchaka, steve.dower, josh.r, Aaron Hall, slam, xtreak |
2020-02-27 15:57:52 | brandtbucher | set | messageid: <1582819072.91.0.675459966939.issue36144@roundup.psfhosted.org> |
2020-02-27 15:57:52 | brandtbucher | link | issue36144 messages |
2020-02-27 15:57:52 | brandtbucher | create | |
|