This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: clock_gettime: Add new identifier CLOCK_UPTIME_RAW for Darwin
Type: enhancement Stage: resolved
Components: macOS Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: nanjekyejoannah, ned.deily, rfmoz, ronaldoussoren, vstinner, xtreak
Priority: normal Keywords: patch, patch, patch

Created on 2019-01-10 07:43 by rfmoz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11503 merged nanjekyejoannah, 2019-01-10 13:56
PR 11503 merged nanjekyejoannah, 2019-01-10 13:56
PR 11503 merged nanjekyejoannah, 2019-01-10 13:56
Messages (6)
msg333366 - (view) Author: Ricardo Fraile (rfmoz) Date: 2019-01-10 07:43
Finally since the release of OSX 10.12 the equivalent from the FreeBSD and OpenBSD "CLOCK_UPTIME" is available on Darwin under the name "CLOCK_UPTIME_RAW":

CLOCK_UPTIME FreeBSD [1]:
Starts at zero when the kernel boots and increments monotonically in SI seconds while the machine is running.

CLOCK_UPTIME OpenBSD [2]:
Time whose absolute value is the time the system has been running and not suspended, providing accurate uptime measurement, both absolute and interval

CLOCK_UPTIME_RAW Darwin [3]:
Clock that increments monotonically, tracking the time since an arbitrary point, unaffected by frequency or time adjustments and not increment while the system is asleep.


It would be useful to have it available on time module [4] for this platform.

As the behaviour is equivalent, maybe it can be assigned to the existing time.CLOCK_UPTIME funtion.




Thanks,



[1] - https://www.freebsd.org/cgi/man.cgi?query=clock_gettime
[2] - https://man.openbsd.org/clock_gettime.2
[3] - http://www.manpagez.com/man/3/clock_gettime_nsec_np/
[4] - https://docs.python.org/3/library/time.htm
msg333376 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-01-10 12:33
I am working on this.
msg333381 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-10 14:23
> As the behaviour is equivalent, maybe it can be assigned to the existing time.CLOCK_UPTIME funtion.

Nah, in Python we map directly to OS constant and don't try to be smart. It's up to the user of these constants to make their own choice.

Use Python functions for portable behavior: time.monotonic(), time.perf_counter(), etc.
msg333406 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-10 16:56
New changeset 572168a016ece1b7346695eb7289190c46f1ae55 by Victor Stinner (Joannah Nanjekye) in branch 'master':
bpo-35702: Add new identifier time.CLOCK_UPTIME_RAW for macOS 10.12 (GH-11503)
https://github.com/python/cpython/commit/572168a016ece1b7346695eb7289190c46f1ae55
msg333407 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-01-10 16:58
Joannah Nanjekye added time.CLOCK_UPTIME_RAW to the master branch (future Python 3.8). We don't add feature to stable versions (like 3.7), so I close the issue.

Thanks Ricardo Fraile for the report, I wasn't aware of this clock ;-)

Note: Until Python 3.8 is released, you can easily hardcode the constant in your application. Such constant rarely change.
msg333413 - (view) Author: Ricardo Fraile (rfmoz) Date: 2019-01-10 18:01
Impressive response time, thanks team!
History
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 79883
2019-01-10 18:01:48rfmozsetmessages: + msg333413
2019-01-10 16:58:35vstinnersetstatus: open -> closed
versions: + Python 3.8
messages: + msg333407

keywords: patch, patch, patch
resolution: fixed
stage: patch review -> resolved
2019-01-10 16:56:41vstinnersetmessages: + msg333406
2019-01-10 14:23:23vstinnersetkeywords: patch, patch, patch

messages: + msg333381
2019-01-10 13:56:52nanjekyejoannahsetkeywords: + patch
stage: patch review
pull_requests: + pull_request11039
2019-01-10 13:56:42nanjekyejoannahsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11038
2019-01-10 13:56:30nanjekyejoannahsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request11037
2019-01-10 12:33:45nanjekyejoannahsetnosy: + nanjekyejoannah
messages: + msg333376
2019-01-10 08:49:29xtreaksetnosy: + xtreak
2019-01-10 08:05:11vstinnersetnosy: + vstinner
2019-01-10 07:43:37rfmozcreate