Feature or enhancement
os.cpu_count() returns the total number of CPUs that the current machine has. On Unix, sched_setaffinity() can reduce the number of CPU "usable" by a process. Currently, os.cpu_count() docstring contains a recipe how to get the number of usable CPUs:
>>> import os; help(os.cpu_count)
cpu_count()
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))``
I propose to add an affinity optional keyword-only parameter to os.cpu_count() which would return len(os.sched_getaffinity(0)).st
UPDATE: Rename usable parameter to affinity.
Linked PRs
Reactions are currently unavailable
Feature or enhancement
os.cpu_count() returns the total number of CPUs that the current machine has. On Unix, sched_setaffinity() can reduce the number of CPU "usable" by a process. Currently, os.cpu_count() docstring contains a recipe how to get the number of usable CPUs:
>>> import os; help(os.cpu_count) cpu_count() 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))``I propose to add an affinity optional keyword-only parameter to os.cpu_count() which would return len(os.sched_getaffinity(0)).st
UPDATE: Rename usable parameter to affinity.
Linked PRs