From 11cbf77f9799e86603bca927a98959c7b94fff80 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Tue, 30 Apr 2024 13:42:13 +0900 Subject: gh-118392: Add note about random.random for multi thread app (gh-118396) --- Doc/library/random.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 8fbce18..6179826 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -59,6 +59,12 @@ from sources provided by the operating system. random number generator with a long period and comparatively simple update operations. +.. note:: + 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. + Bookkeeping functions --------------------- -- cgit v0.12