https://github.com/python/cpython/commit/20c3015e85469cd3b8b22810c9969bc543740196 commit: 20c3015e85469cd3b8b22810c9969bc543740196 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: hauntsaninja <[email protected]> date: 2025-12-19T08:35:34Z summary:
[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 <[email protected]> Co-authored-by: Adam Turner <[email protected]> files: M Doc/library/random.rst diff --git a/Doc/library/random.rst b/Doc/library/random.rst index b1120b3a4d8eb4..dd6b56106afe98 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -78,7 +78,7 @@ Bookkeeping functions instead of the system time (see the :func:`os.urandom` function for details on availability). - If *a* is an int, it is used directly. + If *a* is an int, its absolute value is used directly. With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray` object gets converted to an :class:`int` and all of its bits are used. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
