pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/c6ca562138a0916192f9c3100cae678c616aed29

97560d244c08.css" /> gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APR… · python/cpython@c6ca562 · GitHub
Skip to content

Commit c6ca562

Browse files
gh-113791: Expose CLOCK_MONOTONIC_RAW_APPROX and CLOCK_UPTIME_RAW_APROX on macOS in the time module (#113792)
1 parent b3dba18 commit c6ca562

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Doc/library/time.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,15 @@ These constants are used as parameters for :func:`clock_getres` and
840840

841841
.. versionadded:: 3.3
842842

843+
.. data:: CLOCK_MONOTONIC_RAW_APPROX
844+
845+
Similar to :data:`CLOCK_MONOTONIC_RAW`, but reads a value cached by
846+
the system at context switch and hence has less accuracy.
847+
848+
.. availability:: macOS >= 10.12.
849+
850+
.. versionadded:: 3.13
851+
843852

844853
.. data:: CLOCK_PROCESS_CPUTIME_ID
845854

@@ -899,6 +908,15 @@ These constants are used as parameters for :func:`clock_getres` and
899908

900909
.. versionadded:: 3.8
901910

911+
.. data:: CLOCK_UPTIME_RAW_APPROX
912+
913+
Like :data:`CLOCK_UPTIME_RAW`, but the value is cached by the system
914+
at context switches and therefore has less accuracy.
915+
916+
.. availability:: macOS >= 10.12.
917+
918+
.. versionadded:: 3.13
919+
902920
The following constant is the only parameter that can be sent to
903921
:func:`clock_settime`.
904922

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add ``CLOCK_MONOTONIC_RAW_APPROX`` and ``CLOCK_UPTIME_RAW_APPROX`` to
2+
:mod:`time` on macOS. These are clocks available on macOS 10.12 or later.

Modules/timemodule.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,20 +1993,16 @@ time_exec(PyObject *module)
19931993
return -1;
19941994
}
19951995
#endif
1996-
19971996
#ifdef CLOCK_MONOTONIC
1998-
19991997
if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC) < 0) {
20001998
return -1;
20011999
}
2002-
20032000
#endif
20042001
#ifdef CLOCK_MONOTONIC_RAW
20052002
if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW) < 0) {
20062003
return -1;
20072004
}
20082005
#endif
2009-
20102006
#ifdef CLOCK_HIGHRES
20112007
if (PyModule_AddIntMacro(module, CLOCK_HIGHRES) < 0) {
20122008
return -1;
@@ -2017,7 +2013,6 @@ time_exec(PyObject *module)
20172013
return -1;
20182014
}
20192015
#endif
2020-
20212016
#ifdef CLOCK_THREAD_CPUTIME_ID
20222017
if (PyModule_AddIntMacro(module, CLOCK_THREAD_CPUTIME_ID) < 0) {
20232018
return -1;
@@ -2044,10 +2039,19 @@ time_exec(PyObject *module)
20442039
}
20452040
#endif
20462041
#ifdef CLOCK_UPTIME_RAW
2047-
20482042
if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW) < 0) {
20492043
return -1;
20502044
}
2045+
#endif
2046+
#ifdef CLOCK_MONOTONIC_RAW_APPROX
2047+
if (PyModule_AddIntMacro(module, CLOCK_MONOTONIC_RAW_APPROX) < 0) {
2048+
return -1;
2049+
}
2050+
#endif
2051+
#ifdef CLOCK_UPTIME_RAW_APPROX
2052+
if (PyModule_AddIntMacro(module, CLOCK_UPTIME_RAW_APPROX) < 0) {
2053+
return -1;
2054+
}
20512055
#endif
20522056
}
20532057

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy