From 3212cf831eabd61afa0a8f2850132886787754af Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Thu, 18 May 2023 10:46:18 +0200 Subject: [PATCH 1/2] GH-103545: Add macOS specific constants for ``os.setpriority`` to ``os``. --- Doc/library/os.rst | 11 +++++++++++ Modules/posixmodule.c | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 641e289e77c518..83abb5d5ca1e42 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/Modules/posixmodule.c b/Modules/posixmodule.c index 5022fdeb03703a..531f26ba8bc86f 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 From 2b42ccb9e1dc80bb5c916a0ccc4e5d153216c911 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 18 May 2023 08:52:09 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/macOS/2023-05-18-08-52-04.gh-issue-103545.pi5k2N.rst 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 00000000000000..c40f9460508dd7 --- /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.