Skip to content
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

Clarify "system-wide" in docs for time.monotonic() #102740

Open
orbisvicis opened this issue Mar 15, 2023 · 2 comments
Open

Clarify "system-wide" in docs for time.monotonic() #102740

orbisvicis opened this issue Mar 15, 2023 · 2 comments
Labels
docs Documentation in the Doc dir

Comments

@orbisvicis
Copy link

orbisvicis commented Mar 15, 2023

The documentation for time.monotonic() currently states:

Changed in version 3.5: The function is now always available and always system-wide.

I didn't know what system-wide meant, and so propose expanding the documentation to:

Changed in version 3.5: The function is now always available and always system-wide, that is, the clock is the same for all processes on the system and the reference point does not change after start-up time.

Or anything equally enlightening. This would make it clear, that among other things, the delta may not be valid across reboots.

@AlexWaygood AlexWaygood added the docs Documentation in the Doc dir label Mar 15, 2023
@AlexWaygood AlexWaygood changed the title Clarify "system-wide" in time.monotonic() Clarify "system-wide" in docs for time.monotonic() Mar 15, 2023
@arhadthedev
Copy link
Member

@abalkin, @pganssle (as time experts)

@pkkm
Copy link

pkkm commented Apr 20, 2024

+1 from me. I've just spend time searching the Web and asking on IRC because I wanted to know whether it's safe to use time.monotonic() when starting connections on one thread and timing them out on another. I'd seen it described as a "system-wide" function in the docs, but I had assumed that this is some kind of CPython terminology for working in a similar way on every OS.

I think it would be good for the cross-thread and cross-process behavior of these functions to be documented in a clearer and more prominent way, rather than just being mentioned in the version change notes. Maybe something like this?

An explanation of some terminology and conventions is in order.

  • The term clock scope specifies whether the values returned by a clock use the same reference point, and can be meaningfully compared, between any two processes in the system, between threads but not processes, or only within the same thread.

Functions

  • time.monotonic()

    Clock scope: system.

  • time.perf_counter()

    Clock scope: process on Windows XP and earlier, system everywhere else.

  • time.process_time()

    Clock scope: process.

  • time.thread_time()

    Clock scope: thread.

If this is too much text, then perhaps the docs could use a single suffix consistently (instead of "system-wide" and "process-wide", but "thread-specific") and define it at the top?


Edited to add: While we're discussing the docs of time.monotonic(), the version change notes are also unclear in a different way:

Changed in version 3.5: The function is now always available and always system-wide.
Changed in version 3.10: On macOS, the function is now system-wide.

So what about macOS on Python 3.5 to 3.9?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

4 participants