
03.12.19 21:04, Andrew Barnert via Python-ideas пише:
On Dec 3, 2019, at 02:00, Serhiy Storchaka <storchaka@gmail.com> wrote:
What it will return if implement | for dicts? It should be mentioned in the PEP. It should be tested with a preliminary implementation what behavior is possible and more natural.
What is there to document or test here? There’s no dicts involved in either operator, only a set and a key view, both of which are set types and implement set union.
Oh, sorry, it was a wrong example. Here is the right one:
{(1, 2): 3}.keys() | {4: 5} {(1, 2), 4}
{4: 5} | {(1, 2): 3}.keys() {(1, 2), 4}
How the results will change after implementing PEP 584? It all should be considered in the PEP. Note that dictkeys.__or__ does not return NotImplemented (there is an issue for this), so the PEP can require more wider changes than just adding __or__, __ror__ and __ior__ to dict.