Skip to content

[3.12] gh-109649: Enhance os.cpu_count() documentation #110169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2023

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 1, 2023

  • Doc: Specify that os.cpu_count() counts logicial CPUs.
  • Doc: Specify that os.sched_getaffinity(0) is related to the calling thread.
  • Fix test_posix.test_sched_getaffinity(): restore the old CPU mask when the test completes!

📚 Documentation preview 📚: https://cpython-previews--110169.org.readthedocs.build/

* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!
@gpshead gpshead added the docs Documentation in the Doc dir label Oct 1, 2023
@vstinner
Copy link
Member Author

vstinner commented Oct 1, 2023

Restore removed text

Oops, I removed the len(os.sched_getaffinity(0)) recipe in cpu_count() doc by mistake. I added it back but also clarified again, that it's a number of logical CPUs and this number is specific to the calling thread.

@Yhg1s Yhg1s merged commit 5245b97 into python:3.12 Oct 2, 2023
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR, and @Yhg1s for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@bedevere-app
Copy link

bedevere-app bot commented Oct 2, 2023

GH-110226 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Oct 2, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 2, 2023
…H-110169)

* pythongh-109649: Enhance os.cpu_count() documentation

* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!

* Restore removed text
(cherry picked from commit 5245b97)

Co-authored-by: Victor Stinner <vstinner@python.org>
gpshead pushed a commit that referenced this pull request Oct 3, 2023
) (#110226)

[3.12] gh-109649: Enhance os.cpu_count() documentation (GH-110169)

* gh-109649: Enhance os.cpu_count() documentation

* Doc: Specify that os.cpu_count() counts *logicial* CPUs.
* Doc: Specify that os.sched_getaffinity(0) is related to the calling
  thread.
* Fix test_posix.test_sched_getaffinity(): restore the old CPU mask
  when the test completes!

* Restore removed text
(cherry picked from commit 5245b97)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner vstinner deleted the cpu_count_doc12 branch January 14, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants