From 1e4fa997c06edbf922fa050dbc2466bfd47290e3 Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 21 Jan 2024 03:51:57 +0300 Subject: [PATCH] Optimized it a bit more --- cc-pic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cc-pic.py b/cc-pic.py index ba9dcf2..1cfe32b 100644 --- a/cc-pic.py +++ b/cc-pic.py @@ -55,7 +55,7 @@ class Converter: brightest_i, brightest_l = 0, 0 darkest_i, darkest_l = 0, 768 for oy, line in enumerate(self.PIX_BITS): - for ox, bit in enumerate(line): + for ox in range(len(line)): pix = self._imgdata[x + ox, y + oy] brightness = self._brightness(pix) if brightness > brightest_l: @@ -64,6 +64,7 @@ class Converter: darkest_l, darkest_i = brightness, pix return darkest_i, brightest_i + @lru_cache() def _is_darker(self, bg: int, fg: int, c: int) -> bool: return self._distance(bg, c) < self._distance(fg, c)