[issue1289118] timedelta multiply and divide by floating point

Alexander Belopolsky report at bugs.python.org
Tue Apr 20 23:04:56 CEST 2010


Alexander Belopolsky <alexander.belopolsky at gmail.com> 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 number of microseconds.  A timedelta divided by a number or multiplied by a float is logically a fractional number of microseconds and python does not have a type to represent it.

Daniel's use case of passing timedeltas to a statistical packages is neatly addressed by issue2706's timedelta / timedelta (true) division.  Just strip the dimensionality from your data by dividing each time delta by a chosen unit interval (depending on the problem, a second, a microsecond or even a day may be appropriate).  The result will be a set of floats that your number crunching package will be happy to process.

Another advantage of this approach is that floats can be processed more efficiently than timedeltas with FP arithmetics and intermediate results will be more accurate in most cases.

I recommend accepting issue2706 and rejecting this issue together with issue2706.

----------
nosy: +Alexander.Belopolsky
type:  -> feature request
versions: +Python 3.3 -Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1289118>
_______________________________________


More information about the Python-bugs-list mailing list