Message362774
I think for `|=` the only choice is for it to be essentially an alias to `.update()`. So that means `cm |= other` becomes `cm.maps[0].update(other)`.
For `|` we are breaking new ground and we could indeed make `cm | other` do something like `ChainMap(other, *cm.maps)`.
I've not used ChainMap much (though I've seen some code that uses it) so I'm probably not the best judge of whether this is a good feature to have.
Note that `other | cm` will just do whatever `other.__or__` does, since ChainMap isn't a true subclass of dict, so it will not fall back to `cm.__ror__`. Basically ChainMap will not get control in this case.
Other thoughts:
- Maybe `cm1 | cm2` (both ChainMaps) ought to return `ChainMap(*cm2.maps, *cm1.maps)`?
- These semantics make `|=` behave rather differently from `|`. Is that okay? If not, which of them should change, and how? |
|
Date |
User |
Action |
Args |
2020-02-27 05:59:41 | gvanrossum | set | recipients:
+ gvanrossum, rhettinger, mark.dickinson, scoder, serhiy.storchaka, steve.dower, josh.r, Aaron Hall, slam, xtreak, brandtbucher |
2020-02-27 05:59:41 | gvanrossum | set | messageid: <1582783181.04.0.040346704677.issue36144@roundup.psfhosted.org> |
2020-02-27 05:59:41 | gvanrossum | link | issue36144 messages |
2020-02-27 05:59:40 | gvanrossum | create | |
|