[Python-checkins] cpython: Issue #23530: Improve os.cpu_count() description.

charles-francois.natali python-checkins at python.org
Mon Jul 13 22:02:15 CEST 2015


https://hg.python.org/cpython/rev/b9e3838e9664
changeset:   96906:b9e3838e9664
parent:      96903:02b81a82a57d
user:        Charles-François Natali <cf.natali at gmail.com>
date:        Mon Jul 13 21:01:39 2015 +0100
summary:
  Issue #23530: Improve os.cpu_count() description.
Patch by Julian Taylor.

files:
  Doc/library/multiprocessing.rst |  9 +++++++--
  Doc/library/os.rst              |  5 +++++
  Misc/ACKS                       |  1 +
  Modules/posixmodule.c           |  6 ++++--
  4 files changed, 17 insertions(+), 4 deletions(-)


diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst
--- a/Doc/library/multiprocessing.rst
+++ b/Doc/library/multiprocessing.rst
@@ -869,8 +869,13 @@
 
 .. function:: cpu_count()
 
-   Return the number of CPUs in the system.  May raise
-   :exc:`NotImplementedError`.
+   Return the number of CPUs in the system.
+
+   This number is not equivalent to the number of CPUs the current process can
+   use.  The number of usable CPUs can be obtained with
+   ``len(os.sched_getaffinity(0))``
+
+   May raise :exc:`NotImplementedError`.
 
    .. seealso::
       :func:`os.cpu_count`
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -3596,6 +3596,11 @@
 
    Return the number of CPUs in the system. Returns None if undetermined.
 
+   This number is not equivalent to the number of CPUs the current process can
+   use.  The number of usable CPUs can be obtained with
+   ``len(os.sched_getaffinity(0))``
+
+
    .. versionadded:: 3.4
 
 
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1385,6 +1385,7 @@
 Christian Tanzer
 Steven Taschuk
 Amy Taylor
+Julian Taylor
 Monty Taylor
 Anatoly Techtonik
 Gustavo Temple
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5760,7 +5760,7 @@
     pid: pid_t
     /
 
-Return the affinity of the process identified by pid.
+Return the affinity of the process identified by pid (or the current process if zero).
 
 The affinity is returned as a set of CPU identifiers.
 [clinic start generated code]*/
@@ -11201,7 +11201,9 @@
 /*[clinic input]
 os.cpu_count
 
-Return the number of CPUs in the system; return None if indeterminable.
+Return the number of CPUs in the system; return None if indeterminable.  This
+number is not equivalent to the number of CPUs the current process can use.
+The number of usable CPUs can be obtained with ``len(os.sched_getaffinity(0))``
 [clinic start generated code]*/
 
 static PyObject *

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list