Skip to content

Commit 610aabf

Browse files
karpathyAA-Turner
andauthored
gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (#142483)
If *a* is an integer, the sign of *a* is discarded in the C source code. Clarify this behavior to prevent foot guns, where a common use case might naively assume that flipping the sign will produce different sequences (e.g. for a train/test split of a synthetic data generator in machine learning). Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent 220f0b1 commit 610aabf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/random.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Bookkeeping functions
7878
instead of the system time (see the :func:`os.urandom` function for details
7979
on availability).
8080

81-
If *a* is an int, it is used directly.
81+
If *a* is an int, its absolute value is used directly.
8282

8383
With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray`
8484
object gets converted to an :class:`int` and all of its bits are used.

0 commit comments

Comments
 (0)