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

gh-118392: Add note about random.random for multi thread app by corona10 · Pull Request #118396 · python/cpython · GitHub

/ cpython Public

gh-118392: Add note about random.random for multi thread app - #118396

Merged
corona10 merged 3 commits into
python:mainfrom
corona10:gh-118392-doc
Apr 30, 2024
Merged

gh-118392: Add note about random.random for multi thread app#118396
corona10 merged 3 commits into
python:mainfrom
corona10:gh-118392-doc

Conversation

corona10 commented Apr 29, 2024
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Comment thread Doc/library/random.rst Outdated
Comment on lines +297 to +300
.. warning::
Calling this function in the concurrent use can cause performance degradation.
Instead, Consider using :class:`Random` per thread.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Let's move this up to the module level, perhaps between the security warning and the "see also". The advice is not limited this function.

I think maybe a .. note:: is more appropriate. A red "warning" seems a bit severe to me.

For the text, something like:

The global random number generator and instances of :class:`Random` are thread-safe. However, 
in the free-threaded build, concurrent calls to the global generator or to the same instance of :class:`Random`
may encounter contention and poor performance. Consider using separate instances of :class:`Random`
per thread instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I agree. This replaces my comment.

Comment thread Doc/library/random.rst Outdated

bedevere-app Bot commented Apr 29, 2024

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

corona10 changed the title gh-118392: Add warning about random.random for multi thread app gh-118392: Add note about random.random for multi thread app Apr 29, 2024

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

bedevere-app Bot commented Apr 30, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

corona10 merged commit 11cbf77 into python:main Apr 30, 2024
corona10 deleted the gh-118392-doc branch April 30, 2024 04:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 topic-free-threading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL