[Python-ideas] Add additional special method lookups to math module

Terry Reedy tjreedy at udel.edu
Thu Nov 10 02:32:56 CET 2011


On 11/9/2011 7:29 PM, Greg Ewing wrote:
> On 10/11/11 12:02, Steven D'Aprano wrote:
>
>> However, how far should we go? Does every function in the math module
>> require
>> a dunder method, e.g. __degrees__ ? What happens if we add more
>> functions, say
>> math.bessel?
>
> Another approach to all this would be to provide generic implementations
> of the math functions in terms of the basic arithmetic operations.

Perhaps in a gmath (generic math) module.

 > While
> this wouldn't always be as fast as using type-specific methods, it would
> at least work with all number-like types and would extend easily to any
> new functions we might add without having to update every existing
> numeric type.
>
> It might even be possible to support type-specific accelerations of these
> generic implementations using a __polynomial__ method that takes a list
> of coefficients, or maybe a function for generating the coefficients.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list