On Mon, Dec 2, 2019 at 8:39 PM Kyle Stanley <aeros...@gmail.com> wrote:

> Also, I think it's worth noting that we can optimize the actual behavior
> of the in-place operator under the hood, similar to what is done with
> consecutive string concatenations [2]. Of course, the optimization wouldn't
> be the same as it is with strings (since strings are immutable and dicts
> are mutable), but it still works as an example. IMO, that's a significant
> benefit of high-level languages such as Python: we can simplify the syntax
> while optimizing the exact behavior in the internals.
>

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.

-- 
--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/BYK7SRJW6OY5J3CV36XOVU32SBE7PV4L/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to