On 07/07/2014 06:58 PM, Steven D'Aprano wrote:
On Mon, Jul 07, 2014 at 04:52:17PM -0700, Ethan Furman wrote:
On 07/07/2014 04:49 PM, Benjamin Peterson wrote:

Probably the best argument for the behavior is that "x is y" should
imply "x == y", which preludes raising an exception. No such invariant
is desired for ordering, so default implementations of < and > are not
provided in Python 3.

Nice.  This bit should definitely make it into the doc patch if not already
in the docs.

However, saying this should not preclude classes where this is not the
case, e.g. IEEE-754 NANs. I would not like this wording (which otherwise
is very nice) to be used in the future to force reflexivity on object
equality.

https://en.wikipedia.org/wiki/Reflexive_relation

To try to cut off arguments:

- Yes, it is fine to have the default implementation of __eq__
   assume reflexivity.

- Yes, it is fine for standard library containers (lists, dicts,
   etc.) to assume reflexivity of their items.

- I'm fully aware that some people think the non-reflexivity of
   NANs is logically nonsensical and a mistake. I do not agree
   with them.

- I'm not looking to change anything here, the current behaviour
   is fine, I just want to ensure that an otherwise admirable doc
   change does not get interpreted in the future in a way that
   prevents classes from defining __eq__ to be non-reflexive.

+1
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to