[issue36144] Dictionary addition. (PEP 584)

2020-02-25 Thread Steve Dower
Steve Dower added the comment: That's a much simpler example. And of course: >>> z[False] = False >>> z {0: False} So the precedent is well established that the key doesn't get updated with the value. No further questions, yer honour ;) -- ___

[issue36144] Dictionary addition. (PEP 584)

2020-02-25 Thread Brandt Bucher
Brandt Bucher added the comment: As a somewhat simpler example: >>> f = {False: False} >>> z = {0: 0} >>> f | z {False: 0} >>> {**f, **z} {False: 0} >>> f.update(z); f {False: 0} Though these hairier cases aren't explicitly addressed, the conflict behavior is covered in the Rationale and

[issue36144] Dictionary addition. (PEP 584)

2020-02-25 Thread Steve Dower
Steve Dower added the comment: Not sure if this is a big deal or not, and it seems likely that the preexisting behaviour of .update() and ** unpacking have already decided it, but is it intentional that you end up with the first-seen key and the last-seen value in the case of collisions?

[issue36144] Dictionary addition. (PEP 584)

2020-02-25 Thread Brandt Bucher
Change by Brandt Bucher : -- pull_requests: +18020 pull_request: https://github.com/python/cpython/pull/18659 ___ Python tracker ___

[issue36144] Dictionary addition. (PEP 584)

2020-02-25 Thread Guido van Rossum
Guido van Rossum added the comment: Yup, great plan. On Mon, Feb 24, 2020 at 22:29 Brandt Bucher wrote: > > Brandt Bucher added the comment: > > My current PR plans are: > > - Docs. This will include the dict docs and the whatsnew 3.9. I assume we > have no plans to cover this in the

[issue36144] Dictionary addition. (PEP 584)

2020-02-24 Thread Brandt Bucher
Brandt Bucher added the comment: My current PR plans are: - Docs. This will include the dict docs and the whatsnew 3.9. I assume we have no plans to cover this in the tutorials, etc. Let me know if I'm missing anything here. - collections.defaultdict, with tests. I don't think this needs

[issue36144] Dictionary addition. (PEP 584)

2020-02-24 Thread Guido van Rossum
Guido van Rossum added the comment: While the main code has been merged now, I propose to keep this issue open until some other things have happened: - Documentation - Add | operators to some dict subclasses in the stdlib - (What else?) -- ___

[issue36144] Dictionary addition. (PEP 584)

2020-02-24 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset eb8ac57af26c4eb96a8230eba7492ce5ceef7886 by Brandt Bucher in branch 'master': bpo-36144: Dictionary Union (PEP 584) (#12088) https://github.com/python/cpython/commit/eb8ac57af26c4eb96a8230eba7492ce5ceef7886 --

[issue36144] Dictionary addition. (PEP 584)

2020-02-24 Thread Guido van Rossum
Guido van Rossum added the comment: PEP 584 has been approved by the Steering Council (at my recommendation). We will shortly begin landing PRs related to this. -- versions: +Python 3.9 -Python 3.8 ___ Python tracker

[issue36144] Dictionary addition. (PEP 584)

2019-12-12 Thread Aaron Hall
Aaron Hall added the comment: Another obvious way to do it, but I'm +1 on it. A small side point however - PEP 584 reads: > To create a new dict containing the merged items of two (or more) dicts, one > can currently write: > {**d1, **d2} > but this is neither obvious nor easily

[issue36144] Dictionary addition. (PEP 584)

2019-03-05 Thread STINNER Victor
STINNER Victor added the comment: > Is this issue directly or indirectly related to the PEP 584 "Add + and - > operators to the built-in dict class"? > https://www.python.org/dev/peps/pep-0584/ Ah yes, it's written in the title of the PR. I add it to the bug title as well. -- title:

[issue36144] Dictionary addition. (PEP 584)

2019-03-05 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36144] Dictionary addition.

2019-03-05 Thread STINNER Victor
STINNER Victor added the comment: Is this issue directly or indirectly related to the PEP 584 "Add + and - operators to the built-in dict class"? https://www.python.org/dev/peps/pep-0584/ -- nosy: +vstinner ___ Python tracker

[issue36144] Dictionary addition.

2019-03-04 Thread Stefan Behnel
Stefan Behnel added the comment: > should we also implement +/+= for sets? The question is: what would that do? The same as '|=' ? That would be rather confusing, I think. "|" (meaning: "or") seems a very natural operation for sets, in the same way that "|" operates on bits in integers.

[issue36144] Dictionary addition.

2019-03-04 Thread Viktor Kharkovets
Viktor Kharkovets added the comment: If we're going to forget about commutativity of +, should we also implement +/+= for sets? -- nosy: +slam ___ Python tracker ___

[issue36144] Dictionary addition.

2019-02-28 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Current python-ideas thread for the issue : https://mail.python.org/pipermail/python-ideas/2019-February/055509.html -- ___ Python tracker

[issue36144] Dictionary addition.

2019-02-28 Thread Josh Rosenberg
Josh Rosenberg 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 +/+=;

[issue36144] Dictionary addition.

2019-02-28 Thread Guido van Rossum
Guido van Rossum added the comment: I changed my mind and am now in favor. Most of the arguments against could also be used against list+list. Counter addition is actually a nice special case of this -- it produces the same keys but has a more sophisticated way of merging values for common

[issue36144] Dictionary addition.

2019-02-28 Thread Josh Rosenberg
Josh Rosenberg added the comment: scoder: dict(X, **M) is broken unless M is known to be string keyed (it used to work, but in Python 3, it will raise a TypeError). It's part of the argument for the additional unpacking generalizations from PEP 448; {**X, **M} does what dict(X, **M) is

[issue36144] Dictionary addition.

2019-02-28 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36144] Dictionary addition.

2019-02-28 Thread Stefan Behnel
Stefan Behnel added the comment: > We already have a syntax for dict merging: {**d1, **d2}. Which doesn't mean that "d1 + d2" isn't much more intuitive than this special-character heavy version. It takes me a while to see the dict merge under that heap of stars. And that's already the

[issue36144] Dictionary addition.

2019-02-28 Thread Raymond Hettinger
Raymond Hettinger added the comment: > In Python, the plus operator for sequences (strings, lists, > tuples) is non-commutative. For sequences, that is obvious and expected, but not so much with mappings where the order of overlapping keys is determined by the left operand and the value

[issue36144] Dictionary addition.

2019-02-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > * It is natural to expect the plus operator to be commutative, but this > operation would necessarily be non-commutative. In Python, the plus operator for sequences (strings, lists, tuples) is non-commutative. But I have other arguments against it: *

[issue36144] Dictionary addition.

2019-02-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: 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

[issue36144] Dictionary addition.

2019-02-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I believe it was proposed and rejected multiple times. -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue36144] Dictionary addition.

2019-02-27 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Python ideas discussion in 2015 : https://mail.python.org/pipermail/python-ideas/2015-February/031748.html LWN summary : https://lwn.net/Articles/635397/ -- nosy: +xtreak ___ Python tracker

[issue36144] Dictionary addition.

2019-02-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: I believe that Guido rejected this when it was proposed a few years ago. -- nosy: +gvanrossum ___ Python tracker ___

[issue36144] Dictionary addition.

2019-02-27 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36144] Dictionary addition.

2019-02-27 Thread Brandt Bucher
Change by Brandt Bucher : -- keywords: +patch pull_requests: +12098 stage: -> patch review ___ Python tracker ___ ___

[issue36144] Dictionary addition.

2019-02-27 Thread Brandt Bucher
New submission from Brandt Bucher : ...as discussed in python-ideas. Semantically: d1 + d2 <-> d3 = d1.copy(); d3.update(d2); d3 d1 += d2 <-> d1.update(d2) Attached is a working implementation with new/fixed tests for consideration. I've also updated collections.UserDict with the new