Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6c01ebcc
Commit
6c01ebcc
authored
Jun 05, 2019
by
Raymond Hettinger
Committed by
GitHub
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37158: Simplify and speed-up statistics.fmean() (GH-13832)
parent
ccf0efbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
Lib/statistics.py
Lib/statistics.py
+4
-4
Misc/NEWS.d/next/Library/2019-06-04-22-25-38.bpo-37158.JKm15S.rst
...S.d/next/Library/2019-06-04-22-25-38.bpo-37158.JKm15S.rst
+1
-0
No files found.
Lib/statistics.py
View file @
6c01ebcc
...
...
@@ -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
:
...
...
Misc/NEWS.d/next/Library/2019-06-04-22-25-38.bpo-37158.JKm15S.rst
0 → 100644
View file @
6c01ebcc
Speed-up statistics.fmean() by switching from a function to a generator.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment