[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-09 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Perfect! Applied in r81020. You're correct that n/10**6 and n/1e6 aren't the same thing, at least for n large enough: Python 2.7b2+ (trunk:81019:81020, May 9 2010, 10:33:17) [GCC 4.2.1 (Apple Inc. build 5659)] on darwin Type help,

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Looks good to me. I definitely think this should go into 2.7 as well; total_seconds has only seen the light of day in the beta releases so far, so it's unlikely we'd break anyone's code with this change. (And IMO this is a bugfix, not a

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: If you want a second (third?) opinion, we could ask Antoine. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: [Antoine declines to offer an opinion.] Committed to py3k in r80979. I moved the Misc/NEWS entry from the 'Library' section to the 'Extension Modules' section. Leaving open for the 2.7 backport. --

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - accepted versions: -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Sat, May 8, 2010 at 10:07 AM, Mark Dickinson rep...@bugs.python.org wrote: .. I definitely think this should go into 2.7 as well;  total_seconds has only seen the light of day in the beta releases so far, so it's

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file17266/issue8644.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Mark Dickinson
New submission from Mark Dickinson dicki...@gmail.com: I just noticed (while responding to issue 8643) that timedelta.total_seconds() has some accuracy problems, especially for negative timedeltas: Python 3.2a0 (py3k:80840:80842, May 7 2010, 12:29:35) [GCC 4.2.1 (Apple Inc. build 5659)] on

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: P.S. This change would also make total_seconds() consistent with division by timedelta(seconds=1): td / timedelta(seconds=1) -0.000123 In fact, this might even be a good way to re-implement total_seconds internally. --

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I am attaching a patch for py3k branch. I am +1 for backporting to 2.7 and I avoided relying on py3k timedelta/timedelta in the patch. The tests and docs will need to be modified for the backport. Technically

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Thanks for the patch! Comments, in increasing order of fussiness: (1) there should be a Py_DECREF(total_microseconds) in the case that the PyLong_FromLong(100L) call fails (2) in the docstring, replace 'loose' by 'lose' (3) also in

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Grr. s/docstring/docs/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___ ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: (1) there should be a Py_DECREF(total_microseconds) ... Yes, regrtest -R is not a substitute for thinking. (2) in the docstring, replace 'loose' by 'lose' Neither is spellcheck. :-) (3) also in the docstring, I

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file17246/issue8644-py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Added file: http://bugs.python.org/file17255/issue8644-py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___

[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-07 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file17254/issue8644-py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8644 ___