Alexander Belopolsky <[EMAIL PROTECTED]> added the comment:

On Sat, Nov 15, 2008 at 5:08 AM, Mark Dickinson <[EMAIL PROTECTED]> wrote:
>
> Mark Dickinson <[EMAIL PROTECTED]> added the comment:
>
>> timedelta / <float or int> should be disallowed in true division mode.
>
> I don't understand this;  why should the division mode affect
> division operations involving timedeltas at all?

Here is how I think about this:  timedeltas are integers in units of
time.  For simplicity, let's assume we always express timedeltas in
microseconds (us), so timedeltas are things like 1us, 2us, etc.  As
with integers,  we can define true division (/) and floor division
(//) so that 3us/2us = 1.5 and 3us//2us = 1.  Note that the result is
dimensionless.  Similarly, you can divide timedeltas by  dimensionless
integers: 3us/2 = 1.5us and 3us//2 = 1us.  However in python you
cannot have a timedelta representing 1.5us, so timedelta(0, 0, 3)/2
should be en error.  In order to have a timedelta/int true division,
we would need to have another type floattimedelta which would be a
floating point number in units of time.

>  The meaning of "/" is unaffected by the division mode for float/float or
> float/int;  why should timedeltas be any different?

Because they are integers.  If we had a floattimedelta type that would
store timestamp as a float, its division would rightfully not be
affected by the division mode.

> I vote +1 for timedelta/timedelta and timedelta/float (regardless
> of division mode).

What do you vote  timedelta/timedelta should produce in floor division
mode: an int or a float? and what should  timedelta/float produce: a
timedelta or a float?

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2706>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to