]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-142527: Docs: Clarify that random.seed() discards the sign of an integer...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 19 Dec 2025 08:34:54 +0000 (09:34 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Dec 2025 08:34:54 +0000 (08:34 +0000)
commitb46ce52a532623dd8669d8840b07f94cefa3e3fa
treed052ab0b9c9d739de32bc3fd88737371830d2a6a
parente48fb94d8c0841b5991056aeda4c3c4f60577dff
[3.14] gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (GH-142483) (#142970)

gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (GH-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).
(cherry picked from commit 610aabfef2f90dc1a274703779615aa5b7fbbb3a)

Co-authored-by: Andrej <andrej.karpathy@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Doc/library/random.rst