This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Redundant call to round in delta_new
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.henrie, vstinner
Priority: normal Keywords: patch

Created on 2020-01-06 20:22 by alex.henrie, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17877 merged alex.henrie, 2020-01-06 20:25
Messages (4)
msg359465 - (view) Author: Alex Henrie (alex.henrie) * Date: 2020-01-06 20:22
The delta_new function in _datetimemodule.c currently contains the following code:

    /* Round to nearest whole # of us, and add into x. */
    double whole_us = round(leftover_us);
    int x_is_odd;
    PyObject *temp;

    whole_us = round(leftover_us);

The second call to the round function produces the same result as the first call and can therefore be safely eliminated.
msg359588 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-08 12:52
New changeset 998c54948a29cf5bd8bfa49f973f1ce5855004a0 by Victor Stinner (Alex Henrie) in branch 'master':
bpo-39237, datetime: Remove redundant call to round from delta_new (GH-17877)
https://github.com/python/cpython/commit/998c54948a29cf5bd8bfa49f973f1ce5855004a0
msg359589 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-08 12:53
Thanks Alex Henrie, I merged your PR. I don't think that it's worth it to backport such cleanup change to stable branches.
msg359616 - (view) Author: Alex Henrie (alex.henrie) * Date: 2020-01-08 17:45
Thank you!
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83418
2020-01-08 17:45:59alex.henriesetmessages: + msg359616
2020-01-08 12:53:20vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg359589

stage: patch review -> resolved
2020-01-08 12:52:48vstinnersetnosy: + vstinner
messages: + msg359588
2020-01-06 20:25:22alex.henriesetkeywords: + patch
stage: patch review
pull_requests: + pull_request17293
2020-01-06 20:22:49alex.henriecreate