Skip to content

Commit

Permalink
Merge pull request #7599 from florath/ImageStat_getcount_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Dec 4, 2023
2 parents d7fa0b9 + 90e1e94 commit fe26900
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/PIL/ImageStat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
# See the README file for information on usage and redistribution.
#

import functools
import math
import operator


class Stat:
Expand Down Expand Up @@ -69,10 +67,7 @@ def minmax(histogram):
def _getcount(self):
"""Get total number of pixels in each layer"""

v = []
for i in range(0, len(self.h), 256):
v.append(functools.reduce(operator.add, self.h[i : i + 256]))
return v
return [sum(self.h[i : i + 256]) for i in range(0, len(self.h), 256)]

def _getsum(self):
"""Get sum of all pixels in each layer"""
Expand Down

0 comments on commit fe26900

Please sign in to comment.