Message170776
On Sep 19, 2012, at 5:36 PM, Ram Rachum <report@bugs.python.org> wrote:
> Why would we use float to represent the ratio of the bonus to the client?
Because float is the builtin type that Python provides to represent such quantities.
> Why would we risk imprecision there when Decimal provides us with perfect precision?
Python float is a much simpler and more efficient type than Decimal. One should have a really good reason to introduce Decimal in the program. In case of money, Decimal provides a *lower* precision alternative to float together with the control over rounding direction. This is important in applications where fractions of a penny have to be dealt with in very precise manner.
In your application, float is a perfectly good type to represent 15% bonus. Even if your customers insist on microsecond precision, float is good enough and timedelta resolution will prevent you from supporting higher precision anyways.
As I mentioned before, I would be happy to see greater interoperability between numerical types in Python and interoperability between timedelta and Decimal may come as a side benefit of that effort. However, I don't find your use case to be compelling enough to either justify special case code or to motivate a more general effort. |
|
Date |
User |
Action |
Args |
2012-09-19 22:38:02 | Alexander.Belopolsky | set | recipients:
+ Alexander.Belopolsky, rhettinger, facundobatista, mark.dickinson, belopolsky, vstinner, skrah, cool-RR |
2012-09-19 22:38:02 | Alexander.Belopolsky | link | issue14262 messages |
2012-09-19 22:38:01 | Alexander.Belopolsky | create | |
|