-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-31773: time.perf_counter() uses again double #3964
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
Conversation
This PR fixes a regression of the commit a997c7b which caused precision loss in time.clock() and time.perf_counter() on Windows. |
time.clock() and time.perf_counter() now use again C double internally. Remove also _PyTime_GetWinPerfCounterWithInfo(): use _PyTime_GetPerfCounterDoubleWithInfo() instead on Windows.
Modules/timemodule.c
Outdated
return NULL; | ||
} | ||
return _PyFloat_FromPyTime(t); | ||
return PyFloat_FromDouble(d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just return perf_counter(info)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, done.
Python/pytime.c
Outdated
{ | ||
#ifdef MS_WINDOWS | ||
return _PyTime_GetWinPerfCounterWithInfo(t, info); | ||
return win_perf_counter(&d, info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&d
-> d
The compiler emits a warning, but not an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I didn't have time to test my change. It's now fixed (and I tested it this time).
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Fix also a typo in win_perf_counter()
Thanks for the review @serhiy-storchaka! |
time.clock() and time.perf_counter() now use again C double
internally.
Remove also _PyTime_GetWinPerfCounterWithInfo(): use
_PyTime_GetPerfCounterDoubleWithInfo() instead on Windows.
https://bugs.python.org/issue31773