Message170776
| Author |
Alexander.Belopolsky |
| Recipients |
Alexander.Belopolsky, belopolsky, cool-RR, facundobatista, mark.dickinson, rhettinger, skrah, vstinner |
| Date |
2012年09月19日.22:38:01 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<C43C3A34-3950-4862-BF30-4FE4641DA151@gmail.com> |
| In-reply-to |
<1348090617.44.0.695582293496.issue14262@psf.upfronthosting.co.za> |
| Content |
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. |
|