[issue2706] datetime: define division timedelta/timedelta

2010-04-21 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, yes. Sorry, Victor! There's actually no acknowledgement in Misc/NEWS: it's not *that* common to put acknowledgements there, and I'm not sure it's necessary here, but I've fixed the commit message. -- ___ Pyt

[issue2706] datetime: define division timedelta/timedelta

2010-04-21 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Can someone (Mark?) add an acknowledgment for Victor Stinner to the NEWS file? My py3k patch was 90% code from Victor's trunk patch. -- ___ Python tracker _

[issue2706] datetime: define division timedelta/timedelta

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Grr. s/whatsnew/versionadded/ -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue2706] datetime: define division timedelta/timedelta

2010-04-20 Thread Mark Dickinson
Mark Dickinson added the comment: Stealing from Tennessee... Patch committed to py3k in r80290, r80291, with some minor tweaks and fixes: - rename delta_remailder to delta_remainder - fix memory leak in delta_remainder - add whatsnew entry for docs - note that timedelta // timedelta return

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : Removed file: http://bugs.python.org/file16990/issue2706.diff ___ Python tracker ___ ___ Python-bugs-list mai

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: New patch, issue2706a.diff, implements timedelta % timedelta and addresses Mark's code review comments. With respect to Mark's """ One other thought: with this division operation added, it might be nice to add constants like td_hour, td_minute, etc.

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Tennessee Leeuwenburg
Tennessee Leeuwenburg added the comment: On Tue, Apr 20, 2010 at 6:46 AM, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > Tennessee, are you still tracking this issue? If not, can I steal it from > you. :) > Hi Mark, Please feel free to steal it from me! Wonderful to see so

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I should be able to add timedelta % timedelta and fix the nits that Mark mentioned tonight. -- ___ Python tracker ___ ___

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: Hmm. Having timedelta // int work is *really* peculiar, since it can only be made sense of with reference to some implicit particular chosen unit of time; in this case, that unit of time is apparently microseconds, as far as I can tell. Surely there aren't

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Mark Dickinson
Changes by Mark Dickinson : Removed file: http://bugs.python.org/file16995/unnamed ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: Tennessee, are you still tracking this issue? If not, can I steal it from you. :) > I found out that timedelta % int is not supported in the > released versions while timedelta // int is. Mmm. Interesting. :) I think it would be fine to add timedelta % t

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: By the way, the patch looks good to me, as far as it goes, and I'm +1 on adding all this. I only have the tiniest of nits: - the patch deletes a line at the top of Lib/test/test_datetime.py, for no apparent reason - in delta_add, I think the added 'if' bl

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Mon, Apr 19, 2010 at 4:09 PM, Mark Dickinson wrote: I noticed that as I was porting Victor's patch. I did not add timedelta % timedelta because I found out that timedelta % int is not supported in the released versions while timedelta // int is. I

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Mark Dickinson
Mark Dickinson added the comment: Why is divmod(timedelta, timedelta) supported but not timedelta % timedelta? I think if one is implemented, the other should be too. -- ___ Python tracker ___

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- nosy: -belopolsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue2706] datetime: define division timedelta/timedelta

2010-04-19 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I am attaching a forward port of Victor's timedelta_true_divide_divmod.patch to py3k. -- nosy: +Alexander.Belopolsky Added file: http://bugs.python.org/file16990/issue2706.diff ___ Python tracker

[issue2706] datetime: define division timedelta/timedelta

2010-04-12 Thread R. David Murray
R. David Murray added the comment: It's too late for 2.7 anyway. -- nosy: +r.david.murray priority: -> normal versions: +Python 3.2 -Python 2.7, Python 3.1 ___ Python tracker __

[issue2706] datetime: define division timedelta/timedelta

2010-04-12 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Is there a good reason why this issue is languishing? The requested functionality seems to be well motivated, simple to implement with few objections resolved in the discussion. I wonder if it would be helpful to limit this patch to 3.x series. That wa

[issue2706] datetime: define division timedelta/timedelta

2010-03-27 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +merwok ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

[issue2706] datetime: define division timedelta/timedelta

2009-04-08 Thread Tennessee Leeuwenburg
Changes by Tennessee Leeuwenburg : -- assignee: -> tleeuwenb...@gmail.com ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue2706] datetime: define division timedelta/timedelta

2009-03-25 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: Well, this already happen with other types: >>> a = 100 >>> a //= 2.0 >>> a 50.0 >>> d = datetime.datetime.now() >>> d -= datetime.datetime.now() >>> d datetime.timedelta(-1, 86391, 609000) See http://docs.python.org/reference/datamodel.html#object._

[issue2706] datetime: define division timedelta/timedelta

2009-03-24 Thread Jess Austin
Jess Austin added the comment: A comment on the two most recent patches... For both of these, we can do the following: >>> from datetime import timedelta >>> td = timedelta(12) >>> td datetime.timedelta(12) >>> td //= 3 >>> td datetime.timedelta(4) >>> td //= timedelta(2) >>> td 2 # C

[issue2706] datetime: define division timedelta/timedelta

2009-03-21 Thread webograph
webograph added the comment: i don't think this can be solved in a way that is independent of the chosen unit, as it requires a concept of "whole time-units" (as in "whole numbers"); whether these be seconds or minutes would be completely arbitrary. (`5 minutes % 3 = 0 minutes` would be true if

[issue2706] datetime: define division timedelta/timedelta

2009-03-10 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: On Tue, Mar 10, 2009 at 5:15 PM, Tennessee Leeuwenburg wrote: .. > 2) Allow divmod, the operator '%', to be applied to two timedeltas (e.g. > td1 % td2). I think there is some debate here about whether the return > value be an integer in microsends, or a

[issue2706] datetime: define division timedelta/timedelta

2009-03-10 Thread Tennessee Leeuwenburg
Tennessee Leeuwenburg added the comment: Hi all, I'm trying to help out by reviewing issues in the tracker... so this is just a first attempt and I hope it is somewhat useful. This issue covers a number of discrete functional changes. I here review each in turn: 1) Allow truediv, the operato

[issue2706] datetime: define division timedelta/timedelta

2009-03-09 Thread Fredrik Johansson
Fredrik Johansson added the comment: I think datetime division would be a fine application for Fractions. -- message_count: 18.0 -> 19.0 nosy: +fredrikj nosy_count: 7.0 -> 8.0 ___ Python tracker ___

[issue2706] datetime: define division timedelta/timedelta

2009-03-09 Thread Tennessee Leeuwenburg
Changes by Tennessee Leeuwenburg : -- nosy: +tleeuwenb...@gmail.com nosy_count: 6.0 -> 7.0 ___ Python tracker ___ ___ Python-bugs-list

[issue2706] datetime: define division timedelta/timedelta

2008-12-11 Thread STINNER Victor
STINNER Victor added the comment: I'm finally opposed to datetime.totimedelta() => float, I prefer .totimedelta() => (second, microsecond) which means (int,int). But I like timedelta/timedelta => float, eg. to compute a progression percent. Anyone interested by my last patch (implement timed

[issue2706] datetime: define division timedelta/timedelta

2008-11-15 Thread Alexander Belopolsky
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 / should be disallowed in true division mode. > > I don't understand this; why should t

[issue2706] datetime: define division timedelta/timedelta

2008-11-15 Thread STINNER Victor
STINNER Victor <[EMAIL PROTECTED]> added the comment: Some examples to help the choice (using the last patch). int --- 2L >>> print dt2 * 2 3:08:38 >>> print dt1 - dt2 * 2 0:51:22 >>> divmod(dt1, dt2) (2L, datetime.timedelta(0, 3082)) >>> print timedelta(0, 3082) 0:51:22 In 4 hours, you can wa

[issue2706] datetime: define division timedelta/timedelta

2008-11-15 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: By the way, I assume that any plan to add this division would also include adding the inverse operation: timedelta * float -> timedelta. It wouldn't make a whole lot of sense to have one without the other. _

[issue2706] datetime: define division timedelta/timedelta

2008-11-15 Thread Mark Dickinson
Mark Dickinson <[EMAIL PROTECTED]> added the comment: > timedelta / should be disallowed in true division mode. I don't understand this; why should the division mode affect division operations involving timedeltas at all? The meaning of "/" is unaffected by the division mode for float/float o

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread STINNER Victor
STINNER Victor <[EMAIL PROTECTED]> added the comment: @webograph: time_gmtime() and time_localtime() already use function pointer. I prefer function pointer than code duplication! ___ Python tracker <[EMAIL PROTECTED]> _

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: haypo> How? I don't understand your suggestion. Sorry, another case of mail to tracker bug. Here is what I wrote: """ .. you can convert delta to time using an arbitrary anchor date and extract hms that way: >>> x = datetime(1,1,1) +

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread STINNER Victor
STINNER Victor <[EMAIL PROTECTED]> added the comment: > def formatTimedelta(delta): >return "{0}h {1}min {2}sec".format(*str(delta).split(':')) OMG, this is ugly! Conversion to string and reparse the formatted text :-/ Your code doesn't work with different units than hours, minutes or secon

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Oops, the tracker ate some lines from e-mail. Reposting through the web: On Fri, Nov 14, 2008 at 1:28 PM, STINNER Victor <[EMAIL PROTECTED]> wrote: .. > What do you think about: > timedelta / # only with __future__.divison > tim

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Nov 14, 2008 at 1:28 PM, STINNER Victor <[EMAIL PROTECTED]> wrote: .. > What do you think about: > timedelta / # only with __future__.divison > timedelta // > timedelta % > divmod(timedelta, ) > with: > timedelta // int

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: While I agree that divmod may be useful, your particular use case is not convincing. The same can be done easier without divmod: def formatTimedelta(delta): return "{0}h {1}min {2}sec".format(*str(delta).split(':')) or you can conve

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread STINNER Victor
STINNER Victor <[EMAIL PROTECTED]> added the comment: Since timedelta(3) // 2 is already accepted, divmod should also accept integers (but not float). With the last patch and "from __future__ import division", we support: timedelta // timedelta / timedelta divmod(timedelta, timedelta) W

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Also, why not >>> divmod(timedelta(3), 2) (datetime.timedelta(1), datetime.timedelta(1)) ? And where do we stop? :-) On Fri, Nov 14, 2008 at 1:02 PM, Alexander Belopolsky <[EMAIL PROTECTED]> wrote: > On Fri, Nov 14, 2008 at 12:51 PM,

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Nov 14, 2008 at 12:51 PM, STINNER Victor <[EMAIL PROTECTED]> wrote: > > STINNER Victor <[EMAIL PROTECTED]> added the comment: > > Why not also implementing divmod()? It's useful to split a timedelta > into, for example, (hours, m

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread STINNER Victor
STINNER Victor <[EMAIL PROTECTED]> added the comment: Why not also implementing divmod()? It's useful to split a timedelta into, for example, (hours, minutes, seconds): def formatTimedelta(delta): """ >>> formatTimedelta(timedelta(hours=1, minutes=24, seconds=19)) '1h 24min 19sec'

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- nosy: +amaury.forgeotdarc, jribbens versions: +Python 2.7, Python 3.1 ___ Python tracker <[EMAIL PROTECTED]> ___ ___

[issue2706] datetime: define division timedelta/timedelta

2008-11-14 Thread Alexander Belopolsky
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 arg

[issue2706] datetime: define division timedelta/timedelta

2008-07-19 Thread webograph
webograph <[EMAIL PROTECTED]> added the comment: this is the mentioned patch without the function pointers, in case it better fits the python coding style. Added file: http://bugs.python.org/file10946/datetime_datetime_division_dupcode.patch ___ Python track

[issue2706] datetime: define division timedelta/timedelta

2008-04-27 Thread webograph
New submission from webograph <[EMAIL PROTECTED]>: i suggest that division be defined for timedelta1/timedelta2, in that sense that it gives how many times timedelta2 fits in timedelta1 (ie the usual meaning of division), using integer arithmetics for floor division (//) and returning float for t