Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

Also note: That Python ideas thread that xtreak linked ( 
https://mail.python.org/pipermail/python-ideas/2015-February/031748.html ) 
largely rejected the proposal a couple weeks before PEP 448 was approved. At 
the time, the proposal wasn't just about +/+=; that was the initial proposal, 
but operator overloading was heavily criticized for the failure to adhere to 
either addition or concatenation semantics, so alternate constructors and 
top-level functions similar to sorted were proposed as alternatives (e.g. 
merged(dicta, dictb)). The whole thread ended up being about creating an 
approved, built-in way of one-lining: d3 = d1.copy(); d3.update(d2)

A key quote though is that this was needed because there was no other option 
without rolling your own merged function. Andrew Barnert summarized it best:

"I'm +1 on constructor, +0.5 on a function (whether it's called updated or 
merged, whether it's in builtins or collections), +0.5 on both constructor and 
function, -0.5 on a method, and -1 on an operator.

"Unless someone is seriously championing PEP 448 for 3.5, in which case I'm 
-0.5 on anything, because it looks like PEP 448 would already give us one 
obvious way to do it, and none of the alternatives are sufficiently nicer than 
that way to be worth having another."

As it happens, PEP 448 was put in 3.5, and we got the one obvious way to do it.

Side-note: It occurs to me there will be one more "way to do it" in 3.8 
already, thanks to PEP 572:

(d3 := d1.copy()).update(d2)

I think I'll stick with d3 = {**d1, **d2} though. :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36144>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to