Skip to content

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

Merged
merged 2 commits into from
Oct 12, 2017
Merged

bpo-31773: time.perf_counter() uses again double #3964

merged 2 commits into from
Oct 12, 2017

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 12, 2017

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

@vstinner
Copy link
Member Author

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.
return NULL;
}
return _PyFloat_FromPyTime(t);
return PyFloat_FromDouble(d);
Copy link
Member

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)?

Copy link
Member Author

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);
Copy link
Member

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.

Copy link
Member Author

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).

@bedevere-bot
Copy link

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@serhiy-storchaka serhiy-storchaka removed the request for review from a team October 12, 2017 15:24
Fix also a typo in win_perf_counter()
@vstinner vstinner merged commit cba9a0c into python:master Oct 12, 2017
@vstinner vstinner deleted the perf_counter_double branch October 12, 2017 15:51
@vstinner
Copy link
Member Author

Thanks for the review @serhiy-storchaka!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants