Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Doc/library/random.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ be found in any statistics text.

Return the next random floating point number in the range ``0.0 <= X < 1.0``

.. warning::
Calling this function in the concurrent use can cause performance degradation.
Comment thread
terryjreedy marked this conversation as resolved.
Resolved
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.

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.

I agree. This replaces my comment.


.. function:: uniform(a, b)

Expand Down