On 2019-10-21 02:29, Steven D'Aprano wrote:
On Mon, Oct 21, 2019 at 02:02:07AM +0100, MRAB wrote:

In the case of Counter, it supports both + and |.

The proposed operator will replace where there are matching keys. Which operator of Counter does that? Neither.

That's okay. That's what subclasses are for: to support specialised
behaviour.

I've just realised why I prefer | over +:

| is used with sets, which might overlap, so len(x | y) <= len(x) + len(y)

+ is used with lists and strings, which don't overlap, so len(x + y) == len(x) + len(y)

On that basis, dicts are more like sets, IMHO.
_______________________________________________
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/UDCTLMW2BLEUCWLMN4V3VGBCWIJ7QLBO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to