[issue1289118] timedelta multiply and divide by floating point

2010-05-31 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Committed in r81625. Fixed white space and added a note to "new in 3.2" section of the RST doc. -- resolution: -> accepted stage: commit review -> committed/rejected status: open -> closed ___ Python tracker

[issue1289118] timedelta multiply and divide by floating point

2010-05-29 Thread Mark Dickinson
Mark Dickinson added the comment: The patch looks good to me. Please replace the tab characters in datetimemodule.c with spaces, though. :) -- ___ Python tracker ___ ___

[issue1289118] timedelta multiply and divide by floating point

2010-05-27 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- stage: -> commit review Added file: http://bugs.python.org/file17476/issue1289118-withdoc.diff ___ Python tracker ___

[issue1289118] timedelta multiply and divide by floating point

2010-05-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attaching a new patch with documentation changes, additional tests, updated issue8817 patch and a reference leak fix. -- Added file: http://bugs.python.org/file17464/issue1289118+issue8817-withdoc.diff ___ Pyt

[issue1289118] timedelta multiply and divide by floating point

2010-05-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Attaching a combined issue1289118 + issue8817 patch. Datetime code now uses issue8817's _PyLong_Divmod_Near. -- Added file: http://bugs.python.org/file17460/issue1289118+issue8817-nodoc.diff ___ Python tracke

[issue1289118] timedelta multiply and divide by floating point

2010-05-25 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: > By the way, does your patch do the right thing for > timedelta(microseconds=1) / -4.0 No. >>> timedelta(microseconds=1) / -4.0 datetime.timedelta(-1, 86399, 99) (I just copied your python algorithm ...) I will merge with issue 8817 patch and tha

[issue1289118] timedelta multiply and divide by floating point

2010-05-25 Thread Mark Dickinson
Mark Dickinson added the comment: There's a patch in issue 8817 that exposes a round-to-nearest form of divmod in a function called _PyLong_Divmod_Near; this would save on duplication of code. -- ___ Python tracker

[issue1289118] timedelta multiply and divide by floating point

2010-05-25 Thread Mark Dickinson
Mark Dickinson added the comment: By the way, does your patch do the right thing for timedelta(microseconds=1) / -4.0 ? Because my Python code doesn't. :) [If n is negative, then the 2*r > n condition in div_nearest should be 2*r < n instead.] -- __

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Indeed. Here is what I intended: """ >>> from datetime import timedelta as d >>> [d(microseconds=i + .5)//d.resolution for i in range(-10,10)] [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Should this be considered a bug? For

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Mark Dickinson
Mark Dickinson added the comment: Alexander, it looks like Roundup ate some of your message there. :) Yes, ideally I'd say that the constructor should be doing round-half-to-even. Though last time I looked, the constructor looked quite complicated (especially for float inputs); it may not b

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: It looks like we have a consensus on the rounding mode. Note, however that timedelta constructor rounds away from zero at least on Intel/MacOS X: [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Should this be considered a bug?

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Mark Dickinson
Mark Dickinson added the comment: Re rounding: I'll just note that timedelta / timedelta -> float currently does round to nearest; I'd find it quite surprising if float * timedelta -> timedelta didn't round to nearest. -- ___ Python tracker

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Daniel Stutzbach
Daniel Stutzbach added the comment: I don't have a strong feeling about the method of rounding. My thinking is: If my application is sensitive to how the last microsecond is rounded, then I shouldn't be using a type that only gives me 1-microsecond precision. (Likewise, if my application is

[issue1289118] timedelta multiply and divide by floating point

2010-05-24 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a patch that implements Mark's timedelta_arith.py algorithms in C. With rounding well defined, I am close to withdrawing my opposition to supporting mixed timedelta with float operations. There is still one issue that I believe is worth

[issue1289118] timedelta multiply and divide by floating point

2010-05-21 Thread Mark Dickinson
Mark Dickinson added the comment: N.B. There's already logic for doing div_nearest (i.e., divide one integer by another, returning the closest integer to the result) in the long_round function in Objects/longobject.c. It might be worth pulling that logic out and making it available in a _Py

[issue1289118] timedelta multiply and divide by floating point

2010-05-21 Thread Mark Dickinson
Mark Dickinson added the comment: Python reference implementation showing how to do correct rounding. -- Added file: http://bugs.python.org/file17426/timedelta_arith.py ___ Python tracker ___

[issue1289118] timedelta multiply and divide by floating point

2010-05-21 Thread Mark Dickinson
Mark Dickinson added the comment: Alexander, I still don't understand your objection. What's the downside of allowing the multiplication or division of a timedelta by a float? Perhaps it's true that there are applications where timedeltas are best viewed as integers (with an implicitt 'micro

[issue1289118] timedelta multiply and divide by floating point

2010-05-20 Thread Skip Montanaro
Changes by Skip Montanaro : -- nosy: -skip.montanaro ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://

[issue1289118] timedelta multiply and divide by floating point

2010-05-20 Thread Daniel Stutzbach
Changes by Daniel Stutzbach : -- nosy: -agthorr ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.

[issue1289118] timedelta multiply and divide by floating point

2010-05-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: dt.diff does not apply to current SVN version anymore. I am attaching a quick update that does not change the actual calculation performed. See issue1289118-py3k.diff. I am still -1 for the reason I stated before, but I would like to review a working

[issue1289118] timedelta multiply and divide by floating point

2010-05-20 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- assignee: -> belopolsky nosy: +belopolsky -Alexander.Belopolsky ___ Python tracker ___ ___ Pyt

[issue1289118] timedelta multiply and divide by floating point

2010-05-20 Thread Mark Dickinson
Mark Dickinson added the comment: Sorry, dropping this again. I've got caught up with too many non-datetime related issues. -- assignee: mark.dickinson -> ___ Python tracker __

[issue1289118] timedelta multiply and divide by floating point

2010-04-27 Thread Daniel Stutzbach
Changes by Daniel Stutzbach : -- nosy: +stutzbach ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Whoops. I meant to assign this to me, not Skip. -- assignee: skip.montanaro -> mark.dickinson ___ Python tracker ___ ___

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: I'll take a look at Skip's patch. -- assignee: -> skip.montanaro ___ Python tracker ___ ___ Pyth

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Not sure why this is marked for 3.3. -- versions: +Python 3.2 -Python 3.3 ___ Python tracker ___

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: > The timedelta type is fundamentally an integer type. I disagree strongly with this, and find this a bizarre point of view. Regardless of how the timedelta is stored internally, it's used to represent physical times. I doubt there are many applications tha

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I meant rejecting issue1083, of course. -- ___ Python tracker ___ ___ Python-bugs-list mail

[issue1289118] timedelta multiply and divide by floating point

2010-04-20 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: This is in a way more similar to issue1083 than to issue2706. I am -1 on this RFE for the same reason as I am opposing allowing true division of timedelta by an int. The timedelta type is fundamentally an integer type. A type delta is just a certain

[issue1289118] timedelta multiply and divide by floating point

2008-12-22 Thread STINNER Victor
STINNER Victor added the comment: I like this idea, it's the opposite of the issue #2706. -- nosy: +haypo ___ Python tracker ___ __

[issue1289118] timedelta multiply and divide by floating point

2007-09-01 Thread Skip Montanaro
Skip Montanaro added the comment: Ummm... make that: "I'll implement multiplication." _ Tracker <[EMAIL PROTECTED]> _ ___ Python-bugs-list mai

[issue1289118] timedelta multiply and divide by floating point

2007-09-01 Thread Skip Montanaro
Skip Montanaro added the comment: Attached is a diff to the datetime module that implements floating point division. Comments? Is it worthwhile to pursue? If so, I'll implement the other floating point arithmetic operations. -- versions: +Python 2.6 ___