From f5e47c672795ff9dc454aa6afb684aabd028352d Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 27 Aug 2021 00:46:15 +0200 Subject: [PATCH] wallpaper: small optimization --- bin/wallpaper | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/wallpaper b/bin/wallpaper index 1aa1703..33bfc40 100755 --- a/bin/wallpaper +++ b/bin/wallpaper @@ -111,7 +111,12 @@ def get_best_parts(groups, images): best_association = None best_score = 0 for group in groups: - for association in (zip(group, p) for p in itertools.permutations(images)): + associations = [tuple(zip(group, p)) for p in itertools.permutations(images)] + seen = [] + for association in associations: + if association in seen: + continue + seen.append(association) score = 0 association = [WallpaperPart(rectangle=assoc[0], image=assoc[1]) for assoc in association] for assoc in association: