Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I attaching webograph's patch updated to revision 67223 where I added a few tests.
I am +1 on the floor divide changes (allowing timedelta // timedelta), but I am not sure how true division should work if at all. For the sake of argument, let's assume from __future__ import division or py3k. Currently: >>> timedelta(1)/2 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int' >>> timedelta(1)/timedelta(2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'datetime.timedelta' With this patch, timedelta(1)/2 is still unsupported, but >>> timedelta(1)/timedelta(2) 0.5 Note that this is probably correct behavior because timedelta/int true division does not make much sense, but there is a proposal (see issue1083) to make timedelta/int equivalent to timedelta//int. (I am against issue1083 proposal and for webograph's approach, but this needs to be further discussed.) Also, I've added a test that demonstrates the following behavior: >>> int(timedelta.min/(timedelta.min//3)) 2 This is not a bug in webograph's patch, but rather a bug in long true division, but it shows that true division may not be as useful as it seems. ---------- nosy: +belopolsky Added file: http://bugs.python.org/file12010/timedeltadiv.parch _______________________________________ 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