On 2/3/20 3:07 PM, Sebastian Berg wrote:
That would mean adding `operator.equivalent(a, b) -> bool` which would
allow float to override the result and let
`operator.equivalent_value(float("NaN"), float("NaN))` return True;
luckily very few types would actually override the operation.

You misunderstand what's going on here.  Python deliberately makes float('NaN') != float('NaN'), and in fact there's special code to ensure that behavior.  Why?  Because it's mandated by the IEEE 754 floating-point standard.

   https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN

This bizarre behavior is often exploited by people exploring the murkier corners of Python's behavior.  Changing it is (sadly) not viable.


//arry/

_______________________________________________
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/GOJNWAJSFHBSCCJD2RYWNDRN7RJHYWD3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to