From: Raymond Hettinger Date: Wed, 30 Jan 2019 21:30:20 +0000 (-0800) Subject: Document differences between random.choices() and random.choice(). (GH-11703) X-Git-Tag: v3.8.0a1~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40ebe948e97b47fc84c8f527910063286a174b25;p=python Document differences between random.choices() and random.choice(). (GH-11703) --- diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 4f251574a3..a543ff016a 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -162,6 +162,13 @@ Functions for sequences with the :class:`float` values returned by :func:`random` (that includes integers, floats, and fractions but excludes decimals). + For a given seed, the :func:`choices` function with equal weighting + typically produces a different sequence than repeated calls to + :func:`choice`. The algorithm used by :func:`choices` uses floating + point arithmetic for internal consistency and speed. The algorithm used + by :func:`choice` defaults to integer arithmetic with repeated selections + to avoid small biases from round-off error. + .. versionadded:: 3.6