[Python-ideas] Dict joining using + and +=

Stefan Behnel stefan_ml at behnel.de
Fri Mar 1 10:57:32 EST 2019


Rémi Lapeyre schrieb am 01.03.19 um 16:44:
> Le 1 mars 2019 à 16:04:47, Stefan Behnel a écrit:
>> I think the behaviour makes sense when you know how it's implemented (keys
>> are stored separately from values).
> 
> Is a Python user expected to know the implementation details of all mappings
> thought?

No, it just helps _me_ in explaining the behaviour to myself. Feel free to
look it up in the documentation if you prefer.


>> I would have been less surprised if the
>> keys had also been reordered, but well, this is how it is now in Py3.6+, so
>> this is how it's going to work also for the operator.
>>
>> No *additional* surprises here. ;)
> 
> There is never any surprises left once all details have been carefully worked
> out but having `+` for mappings make it looks like an easy operation whose
> meaning is non ambiguous and obvious.
> 
> I’m still not convinced that it the meaning is obvious, and gave an example
> in my other message where I think it could be ambiguous.

What I meant was that it's obvious in the sense that it is no new behaviour
at all. It just provides an operator for behaviour that is already there.

We are not discussing the current behaviour here. That ship has long sailed
with the release of Python 3.6 beta 1 back in September 2016. The proposal
that is being discussed here is the new operator.

Stefan



More information about the Python-ideas mailing list