]> granicus.if.org Git - python/commitdiff
Issue #23530: Improve os.cpu_count() description.
authorCharles-François Natali <cf.natali@gmail.com>
Mon, 13 Jul 2015 20:01:39 +0000 (21:01 +0100)
committerCharles-François Natali <cf.natali@gmail.com>
Mon, 13 Jul 2015 20:01:39 +0000 (21:01 +0100)
Patch by Julian Taylor.

Doc/library/multiprocessing.rst
Doc/library/os.rst
Misc/ACKS
Modules/posixmodule.c

index 8703f8f5ecacfc22ae4893e4872e51d5c42d056c..e74430df7e10d24199968b73281788037c42be9a 100644 (file)
@@ -869,8 +869,13 @@ Miscellaneous
 
 .. 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`
index 16e5019f862208b80af335e461f47a6936e5805a..0acb8a570f7523008a62aebc8cde680103fb9e85 100644 (file)
@@ -3596,6 +3596,11 @@ Miscellaneous System Information
 
    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
 
 
index 8a007ea9dcb76ffb4637217b2fdbfc73a85abfbb..e4ba783953fb492ee9348cffcbb7458b51fd9e49 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1385,6 +1385,7 @@ William Tanksley
 Christian Tanzer
 Steven Taschuk
 Amy Taylor
+Julian Taylor
 Monty Taylor
 Anatoly Techtonik
 Gustavo Temple
index ec8c526c0aac96469fb0acb62ace1a7fae192923..23d74a3e0e2fb545a1957ebdca32ca1050912beb 100644 (file)
@@ -5760,7 +5760,7 @@ os.sched_getaffinity
     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 @@ get_terminal_size(PyObject *self, PyObject *args)
 /*[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 *