https://github.com/python/cpython/commit/c6ca562138a0916192f9c3100cae678c616aed29
commit: c6ca562138a0916192f9c3100cae678c616aed29
branch: main
author: Ronald Oussoren <[email protected]>
committer: ronaldoussoren <[email protected]>
date: 2024-01-08T20:44:00+01:00
summary:

gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on 
macOS in the time module (#113792)

files:
A Misc/NEWS.d/next/Library/2024-01-07-11-45-56.gh-issue-113791.XF5xSW.rst
M Doc/library/time.rst
M Modules/timemodule.c

diff --git a/Doc/library/time.rst b/Doc/library/time.rst
index 577600881676b3..2782a961363666 100644
--- a/Doc/library/time.rst
+++ b/Doc/library/time.rst
@@ -840,6 +840,15 @@ These constants are used as parameters for 
:func:`clock_getres` and
 
    .. versionadded:: 3.3
 
+.. data:: CLOCK_MONOTONIC_RAW_APPROX
+
+   Similar to :data:`CLOCK_MONOTONIC_RAW`, but reads a value cached by
+   the system at context switch and hence has less accuracy.
+
+   .. availability:: macOS >= 10.12.
+
+   .. versionadded:: 3.13
+
 
 .. data:: CLOCK_PROCESS_CPUTIME_ID
 
@@ -899,6 +908,15 @@ These constants are used as parameters for 
:func:`clock_getres` and
 
    .. versionadded:: 3.8
 
+.. data:: CLOCK_UPTIME_RAW_APPROX
+
+   Like :data:`CLOCK_UPTIME_RAW`, but the value is cached by the system
+   at context switches and therefore has less accuracy.
+
+   .. availability:: macOS >= 10.12.
+
+   .. versionadded:: 3.13
+
 The following constant is the only parameter that can be sent to
 :func:`clock_settime`.
 
diff --git 
a/Misc/NEWS.d/next/Library/2024-01-07-11-45-56.gh-issue-113791.XF5xSW.rst 
b/Misc/NEWS.d/next/Library/2024-01-07-11-45-56.gh-issue-113791.XF5xSW.rst
new file mode 100644
index 00000000000000..16e77269813560
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-01-07-11-45-56.gh-issue-113791.XF5xSW.rst
@@ -0,0 +1,2 @@
+Add ``CLOCK_MONOTONIC_RAW_APPROX`` and ``CLOCK_UPTIME_RAW_APPROX`` to
+:mod:`time` on macOS. These are clocks available on macOS 10.12 or later.
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index b3fe175d9b184a..2b0d3900dbddd6 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1993,20 +1993,16 @@ time_exec(PyObject *module)
             return -1;
         }
 #endif
-
 #ifdef CLOCK_MONOTONIC
-
         if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC) < 0) {
             return -1;
         }
-
 #endif
 #ifdef CLOCK_MONOTONIC_RAW
         if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW) < 0) {
             return -1;
         }
 #endif
-
 #ifdef CLOCK_HIGHRES
         if (PyModule_AddIntMacro(module, CLOCK_HIGHRES) < 0) {
             return -1;
@@ -2017,7 +2013,6 @@ time_exec(PyObject *module)
             return -1;
         }
 #endif
-
 #ifdef CLOCK_THREAD_CPUTIME_ID
         if (PyModule_AddIntMacro(module, CLOCK_THREAD_CPUTIME_ID) < 0) {
             return -1;
@@ -2044,10 +2039,19 @@ time_exec(PyObject *module)
         }
 #endif
 #ifdef CLOCK_UPTIME_RAW
-
         if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW) < 0) {
             return -1;
         }
+#endif
+#ifdef CLOCK_MONOTONIC_RAW_APPROX
+        if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW_APPROX) < 0) {
+            return -1;
+        }
+#endif
+#ifdef CLOCK_UPTIME_RAW_APPROX
+        if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW_APPROX) < 0) {
+            return -1;
+        }
 #endif
     }
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to