Message274586
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. |
|
Date |
User |
Action |
Args |
2016-09-06 18:18:24 | tim.peters | set | recipients:
+ tim.peters, mark.dickinson, steven.daprano |
2016-09-06 18:18:24 | tim.peters | set | messageid: <1473185904.87.0.621512440585.issue27975@psf.upfronthosting.co.za> |
2016-09-06 18:18:24 | tim.peters | link | issue27975 messages |
2016-09-06 18:18:24 | tim.peters | create | |
|