]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118392: Add note about random.random for multi thread app (gh-118396)
authorDonghee Na <donghee.na@python.org>
Tue, 30 Apr 2024 04:42:13 +0000 (13:42 +0900)
committerGitHub <noreply@github.com>
Tue, 30 Apr 2024 04:42:13 +0000 (13:42 +0900)
Doc/library/random.rst

index 8fbce18c56f17c921434108f7d4433516609719f..61798263d61195c912143a8a1fb4a07379832dda 100644 (file)
@@ -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
 ---------------------