Message336811
For the record, I'm opposed to the idea.
* Use of the + operator is a temptation to produce new dictionaries rather than update an existing dict in-place which is usually what you want.
* We already have ChainMap() which presents a single view of multiple mappings with any copying.
* It is natural to expect the plus operator to be commutative, but this operation would necessarily be non-commutative.
* Many other APIs are modeled on the dict API, so we should not grow the API unless there is a big win. The effects would be pervasive.
* I don't see other languages going down this path, nor am I seeing dict subclasses that implement this functionality. Those are indications that this more of a "fun thing we could do" rather than a "thing that people need".
* The existing code already reads nicely:
options.update(user_selections)
That reads more like self explanatory English than:
options += user_selections
The latter takes more effort to correctly parse and
makes it less clear that you're working with dicts.
* It isn't self-evident that the right operand needs to be another dictionary. If a person is trying to "add a key / value pair" to an existing dictionary, the "+=" operator would be tempting but it wouldn't work. |
|
Date |
User |
Action |
Args |
2019-02-28 07:36:52 | rhettinger | set | recipients:
+ rhettinger, gvanrossum, serhiy.storchaka, xtreak, brandtbucher |
2019-02-28 07:36:52 | rhettinger | set | messageid: <1551339412.76.0.627363613546.issue36144@roundup.psfhosted.org> |
2019-02-28 07:36:52 | rhettinger | link | issue36144 messages |
2019-02-28 07:36:52 | rhettinger | create | |
|