-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-63207: Use GetSystemTimePreciseAsFileTime() in time.time() #116822
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
Clock resolution measured by the script: #116781 (comment) Before:
After:
|
On a release build (build using
Well, more and more operating have two clocks: one slow but accurate, and one fast but less accurate. Example on Linux:
Python uses CLOCK_REALTIME for time.time(), the most precise one. So it's consistent to use the most accurate clock for time.time() on Windows as well. If tomorrow, performance becomes an issue, we can add a new |
Impressive! Finally Windows will be as good as other platforms here. |
@@ -55,6 +55,14 @@ | |||
#endif | |||
|
|||
|
|||
#ifdef MS_WINDOWS |
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.
Yes, I think checking for MS_WINDOWS
here is sufficient. GetSystemTimePreciseAsFileTime()
, QueryPerformanceCounter()
, and QueryPerformanceFrequency()
are available in the system, app, and game partitions. The old use of GetSystemTimeAdjustment()
actually wasn't supported for app builds. However, that function was used improperly anyway.
Closes dask#8641. _WindowsTime is no longer needed on Windows with Python 3.13. On Windows, Python 3.13 now uses GetSystemTimePreciseAsFileTime() for time.time() and QueryPerformanceCounter() for time.monotonic(). * python/cpython#116781 * python/cpython#116822
Closes #8641. _WindowsTime is no longer needed on Windows with Python 3.13. On Windows, Python 3.13 now uses GetSystemTimePreciseAsFileTime() for time.time() and QueryPerformanceCounter() for time.monotonic(). * python/cpython#116781 * python/cpython#116822
📚 Documentation preview 📚: https://cpython-previews--116822.org.readthedocs.build/