pyrseus.core.sys.get_num_available_cores

pyrseus.core.sys.get_num_available_cores(pid: int | None = None, physical: bool = False)[source]

Returns the number of cores that are available to the given process for scheduling threads, respecting the CPU affinity mask when possible. Think of this as a better version of multiprocessing.cpu_count.

Parameters:
  • pid – process ID to test, on systems that have affinity masks. Defaults to the current process.

  • physical – whether to try only counting the number of physical cores instead of logical cores. Silently ignored on platforms that don’t support querying the physical core count.