From d5bbe5139d6be45c77796945c2ebdbc2a11bfa1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 28 Apr 2018 23:32:08 +0200 Subject: [PATCH] Generate rating calculation promises in list comprehension --- cli.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli.py b/cli.py index be78e0b..83567a7 100755 --- a/cli.py +++ b/cli.py @@ -41,11 +41,10 @@ class Cli: self.args = ap.parse_args() def calculate_ratings(self): - ratings = [] with Pool(processes=cpu_count()) as pool: - for image in self.args.images: - ratings.append((image, pool.apply_async(self.calculate_rating, - (image, self.args.method)))) + ratings = [(image, pool.apply_async(self.calculate_rating, + (image, self.args.method))) + for image in self.args.images] self.image_ratings = {image: promise.get() for image, promise in ratings} @staticmethod