From: Donghee Na Date: Tue, 30 Apr 2024 04:42:13 +0000 (+0900) Subject: gh-118392: Add note about random.random for multi thread app (gh-118396) X-Git-Tag: v3.13.0b1~216 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11cbf77f9799e86603bca927a98959c7b94fff80;p=thirdparty%2FPython%2Fcpython.git gh-118392: Add note about random.random for multi thread app (gh-118396) --- diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 8fbce18c56f1..61798263d611 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 ---------------------