-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-36138: Improve docs about converting datetime.timedelta to scalars. #12137
Conversation
…ing as necessary). (#12003)
Perhaps add a note of caution about rounding errors, and that to get the highest precision, directly calculate the total microseconds as integers? |
@scotchka There's an existing paragraph about the precision loss arising from the conversion to floating point in the In both cases, pointing to |
@ncoghlan The doc currently says "Note that for very large time intervals (greater than 270 years on most platforms) this method will lose microsecond accuracy." But in general, one can also get tripped up with a small interval, for a slightly different problem:
I'm no expert on computer arithmetic, but |
Realized and confirmed that |
@scotchka The precision loss in your short-interval example is coming from using a truncating conversion from
Given that, I'm going to merge this as is for master and 3.7, and if we decide to add extra references to |
GH-12362 is a backport of this pull request to the 3.7 branch. |
…s. (pythonGH-12137) Be explicit that timedelta division converts an overall duration to the interval units given by the denominator. (cherry picked from commit f40b4a0) Co-authored-by: Yasser A <yalshalaan@gmail.com>
https://bugs.python.org/issue36138