<div dir="ltr">something went weird with the google groups mirror of this list -- sorry if this lands twice.<div><br></div><div>-Chris</div><div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Chris Barker</b> <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov">chris.barker@noaa.gov</a>></span><br>Date: Thu, May 14, 2015 at 1:34 PM<br>Subject: Re: [Python-ideas] Add math.iszero() and math.isequal()?<br>To: Neil Girdhar <<a href="mailto:mistersheik@gmail.com">mistersheik@gmail.com</a>><br>Cc: "<a href="mailto:python-ideas@googlegroups.com">python-ideas@googlegroups.com</a>" <<a href="mailto:python-ideas@googlegroups.com">python-ideas@googlegroups.com</a>><br><br><br><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, May 12, 2015 at 11:24 PM, Neil Girdhar <span dir="ltr"><<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">See PEP 485, which appears to be still a draft: <a href="https://www.python.org/dev/peps/pep-0485/" target="_blank">https://www.python.org/dev/peps/pep-0485/</a></div></blockquote><div><br></div></span><div>It's been approved, and it's "just" waiting for me to implement the code and get it reviewed, etc.</div><div><br></div><div>I've been much sidetracked, but hoping to get to in the next couple days....</div><span class=""><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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></div></blockquote></div></div></blockquote><div><br></div></span><div>I'm not familiar with how hashing works for floats, but I can't image this would even work -- == an !== work for floats, then just don't test what people most often want :-)</div><div><br></div><div>Anyway, see the PEP, and the quite long and drawn out discussion on this list a couple months back.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><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><br></span>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R <a href="tel:%28206%29%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a> voice<br>7600 Sand Point Way NE <a href="tel:%28206%29%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a> fax<br>Seattle, WA 98115 <a href="tel:%28206%29%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a> main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</font></span></div></div>
</div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>