Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 forMS_WINDOWS
here is sufficient.GetSystemTimePreciseAsFileTime()
,QueryPerformanceCounter()
, andQueryPerformanceFrequency()
are available in the system, app, and game partitions. The old use ofGetSystemTimeAdjustment()
actually wasn't supported for app builds. However, that function was used improperly anyway.
Closesdask#8641._WindowsTime is no longer needed on Windows with Python 3.13. OnWindows, Python 3.13 now uses GetSystemTimePreciseAsFileTime() fortime.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. OnWindows, Python 3.13 now uses GetSystemTimePreciseAsFileTime() fortime.time() and QueryPerformanceCounter() for time.monotonic().*python/cpython#116781*python/cpython#116822
pythonGH-136068)(cherry picked from commit486587d)Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
pythonGH-136068)(cherry picked from commit486587d)Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
📚 Documentation preview 📚:https://cpython-previews--116822.org.readthedocs.build/