diff options
| author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-06-05 07:39:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-05 07:39:38 -0700 |
| commit | 6c01ebcc0dfc6be22950fabb46bdc10dcb6202c9 (patch) | |
| tree | d3bd04348be7136bd34284c8d1e3616b9679f614 /Lib/statistics.py | |
| parent | ccf0efbb21f6bbf6efd5f8cb560fed11079ce1a2 (diff) | |
| download | cpython-git-6c01ebcc0dfc6be22950fabb46bdc10dcb6202c9.tar.gz | |
bpo-37158: Simplify and speed-up statistics.fmean() (GH-13832)
Diffstat (limited to 'Lib/statistics.py')
| -rw-r--r-- | Lib/statistics.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/statistics.py b/Lib/statistics.py index 012845b8d2..5be70e5ebf 100644 --- a/Lib/statistics.py +++ b/Lib/statistics.py @@ -320,11 +320,11 @@ def fmean(data): except TypeError: # Handle iterators that do not define __len__(). n = 0 - def count(x): + def count(iterable): nonlocal n - n += 1 - return x - total = fsum(map(count, data)) + for n, x in enumerate(iterable, start=1): + yield x + total = fsum(count(data)) else: total = fsum(data) try: |
