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
7fc633f5
Commit
7fc633f5
authored
Dec 04, 2018
by
Raymond Hettinger
Committed by
Miss Islington (bot)
Dec 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments regarding speed/space/entropy trade-offs (GH-10885)
parent
17473347
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
Lib/random.py
Lib/random.py
+13
-0
No files found.
Lib/random.py
View file @
7fc633f5
...
...
@@ -333,6 +333,19 @@ class Random(_random.Random):
# preferred since the list takes less space than the
# set and it doesn't suffer from frequent reselections.
# The number of calls to _randbelow() is kept at or near k, the
# theoretical minimum. This is important because running time
# is dominated by _randbelow() and because it extracts the
# least entropy from the underlying random number generators.
# Memory requirements are kept to the smaller of a k-length
# set or an n-length list.
# There are other sampling algorithms that do not require
# auxiliary memory, but they were rejected because they made
# too many calls to _randbelow(), making them slower and
# causing them to eat more entropy than necessary.
if
isinstance
(
population
,
_Set
):
population
=
tuple
(
population
)
if
not
isinstance
(
population
,
_Sequence
):
...
...
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