[Python-checkins] cpython (3.5): Improve docs for random.seed()
raymond.hettinger
python-checkins at python.org
Sun Sep 4 14:17:55 EDT 2016
https://hg.python.org/cpython/rev/72651343be73
changeset: 103029:72651343be73
branch: 3.5
parent: 103018:e4b6faf22e8d
user: Raymond Hettinger <python at rcn.com>
date: Sun Sep 04 11:17:28 2016 -0700
summary:
Improve docs for random.seed()
files:
Doc/library/random.rst | 7 +++++--
Lib/random.py | 8 +++++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -63,8 +63,11 @@
If *a* is an int, it 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. With version 1,
- the :func:`hash` of *a* is used instead.
+ object gets converted to an :class:`int` and all of its bits are used.
+
+ With version 1 (provided for reproducing random sequences from older versions
+ of Python), the algorithm for :class:`str` and :class:`bytes` generates a
+ narrower range of seeds.
.. versionchanged:: 3.2
Moved to the version 2 scheme which uses all of the bits in a string seed.
diff --git a/Lib/random.py b/Lib/random.py
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -96,10 +96,12 @@
None or no argument seeds from current time or from an operating
system specific randomness source if available.
+ If *a* is an int, all bits are used.
+
For version 2 (the default), all of the bits are used if *a* is a str,
- bytes, or bytearray. For version 1, the hash() of *a* is used instead.
-
- If *a* is an int, all bits are used.
+ bytes, or bytearray. For version 1 (provided for reproducing random
+ sequences from older versions of Python), the algorithm for str and
+ bytes generates a narrower range of seeds.
"""
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list