-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-118392: Add note about random.random for multi thread app #118396
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
Conversation
Doc/library/random.rst
Outdated
.. warning:: | ||
Calling this function in the concurrent use can cause performance degradation. | ||
Instead, Consider using :class:`Random` per thread. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This replaces my comment.
When you're done making the requested changes, leave the comment: |
I have made the requested changes; please review again |
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
📚 Documentation preview 📚: https://cpython-previews--118396.org.readthedocs.build/