<div dir="ltr">See PEP 485, which appears to be still a draft: https://www.python.org/dev/peps/pep-0485/<div><br></div><div>Best,</div><div><br></div><div>Neil</div><div><br></div><div><br>On Tuesday, May 12, 2015 at 3:18:47 AM UTC-4, Mark Summerfield wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">From Python 3.2 it is easy to compare floats, e.g.,<br><br>iszero = lambda x: hash(x) == hash(0)<br>isequal = lambda a, b: hash(a) == hash(b)<br><br>Clearly these are trivial functions (but perphaps math experts could provide better implementations; I'm not proposing the implementations shown, just the functions however they are implemented).<br><br>It seems that not everyone is aware of the issues regarding comparing floats for equality and so I still see code that compares floats using == or !=.<br><br>If these functions were in the math module it would be convenient (since I find I need them in most non-trivial programs), but also provide a place to document that they should be used rather than == or != for floats. (I guess a similar argument might apply to the cmath module?)<br><br><br></div></blockquote></div></div>