Yes, the assumption (and the implementation) is that newly added keys are
inserted at the end, in the order in which the second object produces them
when iterated over. Please do send us a PR for the peps repo!

On Tue, May 19, 2020 at 12:34 PM David Mertz <me...@gnosis.cx> wrote:

> I know this is late in the cycle to think of this.  But I just realized
> the PEP 584 does not say anything about order guarantees.
>
> I think it is safe to assume that existing keys in dictA will not have
> order modified by `dictA |= dictB`.  However, the PEP does not state what
> order we are given when new keys are added.  I reckon it is a kind of
> insertion, so they must occur after the existing keys.  However, stating
> explicitly that the MUST  (or alternately MIGHT NOT) be inserted in the
> order that dictB has seems worth specifying.
>
> Moreover, the new operator explicitly states that it will flexibly deal
> with mapping types other than dict on the right hand side.  So what happens
> with:
>
>     dictA |= unorderedmapB
>
> I think the "reasonable" belief should be that all new keys will be in
> some unspecified order amongst themselves, but all occurring after the old
> keys.  I think a sentence or two explicitly indicating what is promised and
> what is not would be worthwhile.
>
>>
>>    -
>>
>>    PEP 584 <https://www.python.org/dev/peps/pep-0584/>, Union Operators
>>    in dict
>>
>> --
> The dead increasingly dominate and strangle both the living and the
> not-yet born.  Vampiric capital and undead corporate persons abuse
> the lives and control the thoughts of homo faber. Ideas, once born,
> become abortifacients against new conceptions.
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/4OKQ5DARENNMKN7DVX72K46KKWO6PFCQ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--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-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/IT3A33GXLAMNEMCLQTJSS5KJ7ZUSG633/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to