On Tue, Dec 3, 2019 at 2:10 AM Serhiy Storchaka <storch...@gmail.com> wrote:
> 03.12.19 07:04, Guido van Rossum пише: > > Actually there's no need to optimize the |= operator -- for strings we > > have to optimize += *because* strings are immutable, but for dicts we > > would define |= as essentially an alias for .update(), just like the > > relationship between += and .extend() for lists, and then no unnecessary > > objects would be created. > > Yet one question: should |= accept only dicts at right side, or > arbitrary mappings with the keys() method, or even iterables of pairs as > dict.update()? > IMO it should follow the example of sets, and accept Mappings but not the other thing. (If you have the other thing, use update().) > And the same question for |. Should `{} | Mapping()` and `{} | []` work? > Ditto -- {} | Mapping() should work, but {} | [] should not. Steven, please take note -- these kinds of things should be spelled out in the PEP (apologies if they are already in there). -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DIV75M4LRO2M534XM6AUHR67WQWEGI2M/ Code of Conduct: http://python.org/psf/codeofconduct/