[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-18 Thread Jean Abou Samra
Jean Abou Samra added the comment: Okay, understood, thanks for your detailed explanations. -- ___ Python tracker ___ ___

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: Jean, I sympathize a bit with your wish, but decimal was designed for business, not science. Sqrt, exp, and 3 versions of log are the only math methods, and they happen to be the ones with some use in business calculations and statistics. Extended

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-17 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, I don't really buy into the use case. In my experience a nest of existing functions that are designed for floats will somewhere being using a float constant like 0.5, e, pi, or tau. So, just feeding in a decimal input isn't sufficient to get it to

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-17 Thread Jean Abou Samra
Jean Abou Samra added the comment: I would argue that given a function, from math import * def naive_calc_pi(n=100): u = sqrt(8) v = 4 for _ in range(n): v = 2*u*v/(u + v) u = sqrt(u*v) return u when you realize that floats have limited precision (happened to

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-16 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Stefan. This would mostly be a waste. Also, the APIs aren't completely harmonious because the Decimal methods accept an optional context object. -- ___ Python tracker

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-16 Thread Stefan Krah
Stefan Krah added the comment: The top level decimal.py that dispatches to either _decimal or _pydecimal is pure Python. So perhaps these applications could add these methods themselves: >>> import decimal >>> def exp(x): ... return x.exp() ... >>> decimal.exp = exp >>> >>> from

[issue41315] Add mathematical functions as wrappers to decimal.Decimal methods

2020-07-16 Thread Jean Abou Samra
Change by Jean Abou Samra : -- title: Add mathematical functions as wrapper to decimal.Decimal methods -> Add mathematical functions as wrappers to decimal.Decimal methods ___ Python tracker