Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9b7ae96b
Commit
9b7ae96b
authored
Jan 06, 2017
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #29023: Clarify that ints and longs are always deterministic seeds for random.
parent
9220111f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
Doc/library/random.rst
Doc/library/random.rst
+9
-9
Lib/random.py
Lib/random.py
+4
-2
No files found.
Doc/library/random.rst
View file @
9b7ae96b
...
...
@@ -71,17 +71,17 @@ from sources provided by the operating system.
Bookkeeping functions:
.. function:: seed(
[x]
)
.. function:: seed(
a=None
)
Initialize the basic random number generator. Optional argument *x* can be any
:term:`hashable` object. If *x* is omitted or ``None``, current system time is used;
current system time is also used to initialize the generator when the module is
first imported. If randomness sources are provided by the operating system,
they are used instead of the system time (see the :func:`os.urandom` function
for details on availability).
Initialize internal state of the random number generator.
If a :term:`hashable` object is given, deterministic results are only assured
when :envvar:`PYTHONHASHSEED` is disabled.
``None`` or no argument seeds from current time or from an operating
system specific randomness source if available (see the :func:`os.urandom`
function for details on availability).
If *a* is not ``None`` or an :class:`int` or a :class:`long`, then
``hash(a)`` is used instead. Note that the hash values for some types
are nondeterministic when :envvar:`PYTHONHASHSEED` is enabled.
.. versionchanged:: 2.4
formerly, operating system resources were not used.
...
...
Lib/random.py
View file @
9b7ae96b
...
...
@@ -98,12 +98,14 @@ class Random(_random.Random):
self
.
gauss_next
=
None
def
seed
(
self
,
a
=
None
):
"""Initialize internal state
from hashable object
.
"""Initialize internal state
of the random number generator
.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
If a is not None or an int or long, hash(a) is used instead.
If a is not None or is an int or long, hash(a) is used instead.
Hash values for some types are nondeterministic when the
PYTHONHASHSEED environment variable is enabled.
"""
if
a
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment