bpo-36138: Improve docs about converting datetime.timedelta to scalars.#12137
bpo-36138: Improve docs about converting datetime.timedelta to scalars.#12137ncoghlan merged 9 commits intopython:masterfrom 0xYasser:fix-issue-36138
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 <[email protected]>
…s. (GH-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 <[email protected]>
https://bugs.python.org/issue36138