summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2023-05-19 07:15:11 (GMT)
committerGitHub <noreply@github.com>2023-05-19 07:15:11 (GMT)
commit616fcad6e2e10b0d0252e7f3688e61c468c54e6e (patch)
treee967fa271d814f8f3ef741abbf81608b6a09e355
parentfd04bfeaf7a4531120ad450dbd1afc121a2523ee (diff)
downloadcpython-616fcad6e2e10b0d0252e7f3688e61c468c54e6e.zip
cpython-616fcad6e2e10b0d0252e7f3688e61c468c54e6e.tar.gz
cpython-616fcad6e2e10b0d0252e7f3688e61c468c54e6e.tar.bz2
GH-103545: Add macOS specific constants for ``os.setpriority`` to ``os`` (#104606)
This adds a number of PRIO_DARWIN_* constants to the os module for use with os.setpriority. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
-rw-r--r--Doc/library/os.rst11
-rw-r--r--Misc/NEWS.d/next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst1
-rw-r--r--Modules/posixmodule.c12
3 files changed, 24 insertions, 0 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 641e289..83abb5d 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -493,6 +493,17 @@ process and user.
.. versionadded:: 3.3
+.. data:: PRIO_DARWIN_THREAD
+ PRIO_DARWIN_PROCESS
+ PRIO_DARWIN_BG
+ PRIO_DARWIN_NONUI
+
+ Parameters for the :func:`getpriority` and :func:`setpriority` functions.
+
+ .. availability:: macOS
+
+ .. versionadded:: 3.12
+
.. function:: getresuid()
Return a tuple (ruid, euid, suid) denoting the current process's
diff --git a/Misc/NEWS.d/next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst b/Misc/NEWS.d/next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst
new file mode 100644
index 0000000..c40f946
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst
@@ -0,0 +1 @@
+Add ``os.PRIO_DARWIN_THREAD``, ``os.PRIO_DARWIN_PROCESS``, ``os.PRIO_DARWIN_BG`` and ``os.PRIO_DARWIN_NONUI``. These can be used with ``os.setpriority`` to run the process at a lower priority and make use of the efficiency cores on Apple Silicon systems.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 5022fde..531f26b 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -15917,6 +15917,18 @@ all_ins(PyObject *m)
#ifdef PRIO_USER
if (PyModule_AddIntMacro(m, PRIO_USER)) return -1;
#endif
+#ifdef PRIO_DARWIN_THREAD
+ if (PyModule_AddIntMacro(m, PRIO_DARWIN_THREAD)) return -1;
+#endif
+#ifdef PRIO_DARWIN_PROCESS
+ if (PyModule_AddIntMacro(m, PRIO_DARWIN_PROCESS)) return -1;
+#endif
+#ifdef PRIO_DARWIN_BG
+ if (PyModule_AddIntMacro(m, PRIO_DARWIN_BG)) return -1;
+#endif
+#ifdef PRIO_DARWIN_NONUI
+ if (PyModule_AddIntMacro(m, PRIO_DARWIN_NONUI)) return -1;
+#endif
#ifdef O_CLOEXEC
if (PyModule_AddIntMacro(m, O_CLOEXEC)) return -1;
#endif