[issue41303] perf_counter result does not count system sleep time in Mac OS

STINNER Victor report at bugs.python.org
Wed Aug 5 10:59:41 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

> (On which note: Please don't switch macOS to use clock_gettime(CLOCK_MONOTONIC); that would be a breaking change for us!)

Right, I propose to add new clock(s) since people may rely on the current clock(s) specifications.

> At least Linux, macOS, FreeBSD, and Windows all have a way to access a monotonic clock that stops ticking while the system is suspended.

Python also tries to support AIX, OpenBSD, Solaris, Android, etc.
https://pythondev.readthedocs.io/platforms.html#best-effort-and-unofficial-platforms

I'm not sure that all "supported" platforms provide such clock. It's ok if such clock is not available on all platforms. People can fallback on monotonic/perf_counter depending on their need. For example, previously, it was common to write something like:

try: from time import monotonic
except ImportError: from time import time as monotonic # Python 2 or clock not available

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41303>
_______________________________________


More information about the Python-bugs-list mailing list