mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-37158: Simplify and speed-up statistics.fmean() (GH-13832)
This commit is contained in:
parent
ccf0efbb21
commit
6c01ebcc0d
2 changed files with 5 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue