On Thu, Oct 24, 2019 at 1:20 AM Christopher Barker <python...@gmail.com> wrote:
>
> On Wed, Oct 23, 2019 at 5:42 AM Rhodri James <rho...@kynesim.co.uk> wrote:
>>
> frankly, the | is obscure to most of us. And it started as "bitwise or", and 
> evokes the __or__ magic method -- so why are we all convinced that somehow 
> it's inextricably linked to "set union"?

It is because "bitwise or" is very similar to "set union".

You can regard integer as bitset (set of bits).
5 is {bit 1, bit 3} and 6 is {bit 2, bit 3}.  So 5 | 4 is 7 {bit 1,
bit 2, bit 3}.

So reusing | to set union is very natural to me.

But if we use + for dict merging, I think we should add + to set too.
Then the set has `.union()`, `|` and `+` for the same behavior.

Regards,
-- 
Inada Naoki  <songofaca...@gmail.com>
_______________________________________________
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/WWCQBMRZGLAKBK5M4LNZLG3CBURHR3FK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to