[Python-ideas] Including elementary mathematical functions in the python data model (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Sep 26 14:25:29 CEST 2010
- Previous message: [Python-ideas] Including elementary mathematical functions in the python data model
- Next message: [Python-ideas] Including elementary mathematical functions in the python data model
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 26 Sep 2010 22:07:50 +1000 Nick Coghlan <ncoghlan at gmail.com> wrote:
On Sun, Sep 26, 2010 at 9:05 PM, Mark Dickinson <dickinsm-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote: > A less invasive proposal would be just to introduce sin, etc. > magic methods and have math.sin delegate to .sin; i.e., > have math.sin work in exactly the same way that math.floor and > math.ceil currently work. That would be quite nice for e.g., the > decimal module: you'd be able to write something like: > > from math import sqrt > root = (-b + sqrt(bb - 4ac)) / (2a) > > to compute the root of a quadratic equation, and it would work > regardless of whether a, b, c were Decimal instances or floats. > > I'm not sure how I feel about the entailed magic method explosion, though.
Couple that with the extra function call overhead (since these wouldn't have real typeslots) and it still seems like a less than stellar idea. As another use case for solid, efficient generic function support though... great idea :)
At the cost of even more execution overhead? :)
Regards
Antoine.
- Previous message: [Python-ideas] Including elementary mathematical functions in the python data model
- Next message: [Python-ideas] Including elementary mathematical functions in the python data model
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]