<div dir="ltr"><div><div><div><div><div><div><div><div>I think this looks good and I hope it'll get much approval. Thanks for hanging in there! I did a quick review:<br><br></div><div>- Which module should this go into? (I think math, but I don't think you state it.)<br></div><div><br></div>- Sometimes the default relative tolerance is described as 1e-8, sometimes as 1e-9.<br><br></div>- The formula with "abs(a-b) <= max( ... min(..." is missing an all-important close parenthesis. I presume it goes before the last comma. :-)<br><br></div>- What if a tolerance is inf or nan? What if all args are inf or nan?<br><br></div><div>- I'd argue for allowing the tolerances to be floats even if a and b are Decimals. There's not much difference in the outcome. Also, what if exactly one of a and b is Decimal?<br></div><div><br></div>- Your language about complex confuses me. What is z? I'd expect the following behavior:<br></div> - tolerances cannot be complex<br></div> - abs(a-b) is the right thing to use<br></div> Or maybe you meant to say that abs() of the tolerances will be used if they are complex? That makes some sense in case someone just mindlessly passes a real cast to complex (i.e. with a zero imaginary part, or near-zero in case it's the outcome of a very fuzzy computation). But still. Maybe you can just give the formula to be used for complex args, if it is in fact any different from the one for reals?<br><br></div>- For unittests are you proposing to replace assertAlmostEquals or deprecate that and add a new assertIsCloseTo? (I hope the latter.)<br><br>- "there as no benefit" -- as->was<br clear="all"><div class="gmail_extra"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>
</div></div>