On Thu, Aug 26, 2021 at 12:44:18PM +0200, Marc-Andre Lemburg wrote:

> Fair enough. Would it then make sense to at least have all possible
> NAN objects compare equal, treating the extra error information as an
> attribute value rather than a distinct value and perhaps exposing this
> as such ?
> 
> I'm after the "practicality beats purity" here. The math.isnan() test
> doesn't work well in practice, since you'd have to iterate over all
> sequence members and call that test function, which is expensive when
> done in Python.

Yes, it is expensive in Python (but maybe the work Mark Shannon is doing 
will speed up function calls?).

It's even more expensive because Decimals and floats don't support the 
same API for testing for NANs, which makes me sad.

But having NANs compare equal to each other would be a major backwards 
compatibility break, and it would go against the standard.

Right now, the only fast way to check for NANs without worrying about 
their type is to take advantage of the fact that they don't equal 
themselves: `x != x`.



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

Reply via email to