Tim Peters added the comment: The only sane way to do things "like this" is to allow types to define their own special methods (like `__isnan__()`), in which case the math module defers to such methods when they exist. For example, this is how `math.ceil(Fraction)` works, by deferring to `Fraction.__ceil__()`. The math module itself knows nothing else about what `ceil(Fraction)` could possibly mean. All it knows is "if the type has __ceil__ use that, else convert to float first".
I'm also -1 on adding masses of if/else if/else if/.../else constructs to the math module to build in knowledge of the builtin numeric types. Do it "right" or not at all. I'd just be -0 on adding masses of new __isnan__, __isinf__, ..., special methods. They're just not useful enough often enough. ---------- nosy: +tim.peters _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27975> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com