Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99db3fd

Browse files
committed
Elaborate on the calculation used in the random module.
1 parent 67f0b6c commit 99db3fd

1 file changed

Lines changed: 26 additions & 24 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,18 @@ Some smaller changes made to the core Python language are:
515515
New, Improved, and Deprecated Modules
516516
=====================================
517517

518-
Python's standard library is now receiving significant maintenance efforts
519-
and quality improvements.
518+
Python's standard library has undergone significant maintenance efforts and
519+
quality improvements.
520520

521521
The biggest news for Python 3.2 is that the :mod:`email` package and
522-
:mod:`nntplib` modules now work correctly with Python 3.2's bytes/text model.
522+
:mod:`nntplib` modules now work correctly with the bytes/text model in Python 3.
523523
For the first time, there is correct handling of inputs with mixed encodings.
524524

525525
Another significant win is the addition of substantially better support for
526526
*SSL* connections and security certificates.
527527

528-
In addition, many more functions and classes now have a :term:`context manager`
529-
to support convenient and reliable resource clean-up using the
528+
In addition, more functions and classes now have a :term:`context manager` to
529+
support convenient and reliable resource clean-up using the
530530
:keyword:`with`-statement.
531531

532532
email
@@ -930,10 +930,13 @@ random
930930
------
931931

932932
The integer methods in the :mod:`random` module now do a better job of producing
933-
uniform distributions. Previously, they used ``int(n*random())`` which had a
934-
slight bias whenever *n* was not a power of two. The functions and methods
935-
affected are :func:`~random.randrange`, :func:`~random.randint`,
936-
:func:`~random.choice`, :func:`~random.shuffle` and :func:`~random.sample`.
933+
uniform distributions. Previously, they computed selections with
934+
``int(n*random())`` which had a slight bias whenever *n* was not a power of two.
935+
Now, multiple selections are made from a range upto the next power of two and a
936+
selection is kept only when it falls within the range ``0 <= x < n``. The
937+
functions and methods affected are :func:`~random.randrange`,
938+
:func:`~random.randint`, :func:`~random.choice`, :func:`~random.shuffle` and
939+
:func:`~random.sample`.
937940

938941
(Contributed by Raymond Hettinger; :issue:`9025`.)
939942

@@ -1057,21 +1060,20 @@ pdb
10571060

10581061
The :mod:`pdb` debugger module gained a number of usability improvements:
10591062

1060-
- :file:`pdb.py` now has a ``-c`` option that executes commands as given in a
1061-
:file:`.pdbrc` script file.
1062-
- A :file:`.pdbrc` script file can contain ``continue`` and ``next`` commands
1063-
that continue debugging.
1064-
- The :class:`Pdb` class constructor now accepts a *nosigint* argument.
1065-
- new commands: ``l(list)``, ``ll(long list`` and ``source`` for
1066-
listing source code.
1067-
- new commands: ``display`` and ``undisplay`` for showing or hiding
1068-
the value of an expression if it has changed.
1069-
- new command: ``interact`` for starting an interactive interpreter containing
1070-
the global and local names found in the current scope.
1071-
- breakpoints can be cleared by breakpoint number
1072-
1073-
1074-
.. XXX: Create a new section for all changes relating to context managers.
1063+
* :file:`pdb.py` now has a ``-c`` option that executes commands as given in a
1064+
:file:`.pdbrc` script file.
1065+
* A :file:`.pdbrc` script file can contain ``continue`` and ``next`` commands
1066+
that continue debugging.
1067+
* The :class:`Pdb` class constructor now accepts a *nosigint* argument.
1068+
* new commands: ``l(list)``, ``ll(long list`` and ``source`` for
1069+
listing source code.
1070+
* new commands: ``display`` and ``undisplay`` for showing or hiding
1071+
the value of an expression if it has changed.
1072+
* new command: ``interact`` for starting an interactive interpreter containing
1073+
the global and local names found in the current scope.
1074+
* breakpoints can be cleared by breakpoint number
1075+
1076+
10751077
.. XXX: Various ConfigParser changes
10761078
.. XXX: Mention urllib.parse changes
10771079
Issue 9873 (Nick Coghlan):

0 commit comments

Comments
 (0)