]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Small speed-up for NormalDist.samples (GH-94730)
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Mon, 11 Jul 2022 03:34:53 +0000 (22:34 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Jul 2022 03:34:53 +0000 (22:34 -0500)
Lib/statistics.py

index 2d66b0522f19d52632c0f24d73df7c93d9b326bc..a2793d97186860af192c359657fedc27e11d8f62 100644 (file)
@@ -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"