Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

os.process_cpu_count(): get the number CPUs usable by the current process #109649

Closed
Labels
type-featureA feature request or enhancement
@vstinner

Description

@vstinner

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 anaffinity optional keyword-only parameter to os.cpu_count() which would returnlen(os.sched_getaffinity(0)).st

UPDATE: Renameusable parameter toaffinity.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp