]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] 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:35:34 +0000 (09:35 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Dec 2025 08:35:34 +0000 (08:35 +0000)
commit20c3015e85469cd3b8b22810c9969bc543740196
treefa602e3becc642bc7a4ed503eef40a4ca48b1ba6
parentb5a29553d931581e7a007749604b9e5ee5207d73
[3.13] gh-142527: Docs: Clarify that random.seed() discards the sign of an integer input (GH-142483) (#142971)

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