
On Sat, 16 Mar 2019 01:41:59 +1100 Steven D'Aprano <steve@pearwood.info> wrote:
Matrix multiplication is a perfect example: adding the @ operator could have been done in Python 0.1 if anyone had thought of it, but it took 15 years of numerical folk "whinging" about the lack until it happened:
Not so perfect, as the growing use of Python for scientific computing has made it much more useful to promote a dedicated matrix multiplication operator than, say, 15 or 20 years ago. This is precisely why I worded my question this way: what has changed in the last 20 years that make a "+" dict operator more compelling today than it was? Do we merge dicts much more frequently than we did? I don't think so.
Or the infamous := operator, which ultimately is a useful but minor syntactic and semantic change but generated a huge amount of debate, argument and negativity.
... and is likely to be a mistake as well. Justifying future mistakes with past mistakes doesn't sound very reasonable ;-)
I still remember being told in no uncertain terms by the core devs that adding a clear() method to lists was a waste of time because there was already a perfectly good way to spell it with slicing. And then ABCs came along and now lists have a clear method. So opinions change too.
Not really the same problem. The "+" dict operator is not intuitively obvious in its meaning, while a "clear()" method on lists is. I wouldn't mind the new operator if its meaning was clear-cut. But here we have potential for confusion, both for writers and readers of code.
Besides, if I have two dicts with e.g. lists as values, I *really* dislike the fact that the + operator will clobber the values rather than concatenate them. It's a recipe for confusion.
Are you confused that the update method clobbers list values rather than concatenate them? I doubt that you are.
So why would it be confusing to say that + does a copy-and-update?
Because it's named "+" precisely. You know, names are important. ;-) Regards Antoine.