[issue14262] Allow using decimals as arguments to `timedelta`

2014-10-14 Thread Stefan Krah
Changes by Stefan Krah : -- nosy: -skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Sep 19, 2012, at 5:36 PM, Ram Rachum 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

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Ram Rachum
Ram Rachum added the comment: In the example I gave, Decimal is clearly preferred over float. Why would we use float to represent the ratio of the bonus to the client? Why would we risk imprecision there when Decimal provides us with perfect precision? -- _

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Sep 19, 2012 at 4:32 PM, Ram Rachum wrote: > But that number, 1.15, is stored in a Django decimal field. My criticism was towards the idea that one may need to multiply timedelta by a dollar amount or convert a dollar amount to a timedelta. Stor

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Ram Rachum
Ram Rachum added the comment: I can think of millions of use cases. Here's a random one out of those millions: A client is entitled to X hours of service a month. We grant him a promotion where he is allowed 15% more than x, i.e. 1.15*x. But that number, 1.15, is stored in a Django decimal fie

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Sep 19, 2012 at 3:24 PM, Ram Rachum wrote: > I hope this was intended as a joke. If this was an actual criticism, let me > know so > I could explain why it makes sense. It was both. Yes, any use cases will be helpful. Timedelta is already a dec

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Ram Rachum
Ram Rachum added the comment: I hope this was intended as a joke. If this was an actual criticism, let me know so I could explain why it makes sense. -- ___ Python tracker ___ _

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Wed, Sep 19, 2012 at 3:09 PM, Ram Rachum wrote: > One example is decimal fields on Django, used for dollar amounts. .. and since time is money and money is time we should support easy conversion between the two. :-) -- nosy: +Alexander.Belopol

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Ram Rachum
Ram Rachum added the comment: @mark.dickinson: Many different sources. One example is decimal fields on Django, used for dollar amounts. -- ___ Python tracker ___ __

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Mark Dickinson
Mark Dickinson added the comment: > If we can agree on a lossless protocol to communicate floating pointing > numbers of different base What sort of thing did you have in mind? This is sounding like a PEP-level proposal. -- ___ Python tracker

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Mark Dickinson
Mark Dickinson added the comment: @Ram Rachum: out of curiosity, where are your Decimal objects coming from in the first place? -- ___ Python tracker ___ __

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Mark wrote in his comment on issue 15975: > we're looking at significant extra code to implement > Decimal * timedelta Not necessarily. I will only support adding this feature if it can be done without making datetime know about Decimal. If we can agre

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Mark Dickinson
Mark Dickinson added the comment: > (1) timedelta() does no loose precision over the entire range > of timedelta and rounding is documented; Agreed that this should be a requirement. -- ___ Python tracker

[issue14262] Allow using decimals as arguments to `timedelta`

2012-09-19 Thread Mark Dickinson
Changes by Mark Dickinson : -- versions: +Python 3.4 -Python 3.3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-20 Thread Ram Rachum
Ram Rachum added the comment: In some cases we indeed use a timedelta directly, but sometimes we get a "number of hours", and in those cases it's more convenient for us to work with "number of hours" directly. -- ___ Python tracker

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-20 Thread STINNER Victor
STINNER Victor added the comment: "I'm getting an `n_hours` variable for some component of my system. And this value happens to come as a `Decimal`." Can't you modify your program to use timedelta instead of Decimal for n_hours? -- ___ Python tracke

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-20 Thread Ram Rachum
Ram Rachum added the comment: "I'm not completly conviced by the need of supporting Decimal in timedelta constructor. Why do you use Decimal if the result should be a timedelta? Why not using timedelta directly?" What do you mean, "Why not using timedelta directly?" How could I use timedelta

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-19 Thread STINNER Victor
STINNER Victor added the comment: My patch looses precision for big numbers. It's better to convert Decimal to a number of microseconds. Wrong: >>> value=86400*365.25*99+1e-6; print(datetime.timedelta(seconds=value)) 365249634 days, 18:00:00 >>> value=decimal.Decimal(86400*365.25*99)+

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-19 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +skrah ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-13 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am -0 on the feature and -1 on the implementation. Conversion from Decimal to float is explicit by design. Decimal gives the user fine control over rounding issues allowing for either exact arithmetics (trapping inexact operation) or one of several

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-13 Thread Ram Rachum
Ram Rachum added the comment: Thanks for the patch! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-13 Thread STINNER Victor
STINNER Victor added the comment: Attached patch changes timedelta constructor to accept decimal.Decimal. See also the issue #14180. -- keywords: +patch Added file: http://bugs.python.org/file24820/timedelta_decimal.patch ___ Python tracker

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-13 Thread Ram Rachum
Ram Rachum added the comment: I'm not proposing that `timedelta` will use `Decimal` internally, but that it would handle the conversion to `float` itself, instead of the user having to do it. -- ___ Python tracker

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-13 Thread STINNER Victor
STINNER Victor added the comment: The PEP 410 was rejected. See also the issue #13882. -- ___ Python tracker ___ ___ Python-bugs-list

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-12 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +belopolsky, facundobatista, haypo, mark.dickinson, rhettinger ___ Python tracker ___ ___ Python-bug

[issue14262] Allow using decimals as arguments to `timedelta`

2012-03-12 Thread Ram Rachum
New submission from Ram Rachum : Please allow using decimals as arguments to `timedelta`, so the following code won't raise an exception: Python 3.3.0a1 (default, Mar 4 2012, 17:27:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.