FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

os.cpu_count() recommends non-portable len(os.sched_getaffinity(0)) to get usable CPUs · Issue #105972 · python/cpython · GitHub

/ cpython Public

os.cpu_count() recommends non-portable len(os.sched_getaffinity(0)) to get usable CPUs #105972

Description

Documentation

The documentation of os.cpu_count() mentions that to get the the number of usable CPUs one can use len(os.sched_getaffinity(0)). However that's not available in all platforms, for instance in macOS.
For Unix platforms a better approach would be to use os.sysconf('SC_NPROCESSORS_ONLN'), which is also not fully standard, however at least it has been proposed for the next POSIX standard (https://www.austingroupbugs.net/view.php?id=339) and is currently available in many UNIX platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL