[Python-ideas] PEP 485: A Function for testing approximate equality

Andrew Barnert abarnert at yahoo.com
Wed Feb 11 14:32:16 CET 2015


On Feb 10, 2015, at 21:15, Chris Barker <chris.barker at noaa.gov> wrote:

> As far as implementation is concerned, I'm not sure what to do with Decimal: simply cast to floats? or do type-based dispatch? ( Decimal won't auto-convert a float to decimal, so it doesn't "just work" with the default float tolerance. But that's an implementation detail.

One more possibility:

Many of the functions in math don't work on Decimal. And Decimal has its own methods and functions for almost all of them. So you could add Decimal.isclose, and make math.isclose with Decimal values be a TypeError. And considering that a Decimal can handle ridiculous things like 1e-9999 as a relative tolerance, maybe that's even a good thing, not an unfortunate fallback?

(I'll read the rest of it later, but even if you didn't address a single one of my comments, I'm still probably at least +0.5.)


More information about the Python-ideas mailing list