From: Raymond Hettinger Date: Mon, 11 Jul 2022 03:34:53 +0000 (-0500) Subject: Small speed-up for NormalDist.samples (GH-94730) X-Git-Tag: v3.12.0a1~982 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9118afd045a64ca22d4a8cc5d43532607083b2d;p=thirdparty%2FPython%2Fcpython.git Small speed-up for NormalDist.samples (GH-94730) --- diff --git a/Lib/statistics.py b/Lib/statistics.py index 2d66b0522f19..a2793d971868 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -1193,7 +1193,7 @@ class NormalDist: "Generate *n* samples for a given mean and standard deviation." gauss = random.gauss if seed is None else random.Random(seed).gauss mu, sigma = self._mu, self._sigma - return [gauss(mu, sigma) for i in range(n)] + return [gauss(mu, sigma) for _ in repeat(None, n)] def pdf(self, x): "Probability density function. P(x <= X < x+dx) / dx"