From 2f0757e2a4efe593dd34be9b2c75bf487729dd48 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 11 Dec 2015 09:13:52 +0100 Subject: [PATCH] [mod] self note on optimisation --- prosopopee/prosopopee.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 6448b3c..fe1448d 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -18,8 +18,15 @@ class TemplateFunctions(): self.target_dir = target_dir def copy_image(self, image): - shutil.copyfile(os.path.join(self.base_dir, image), os.path.join(self.target_dir, image)) - print os.path.join(self.base_dir, image), "->", os.path.join(self.target_dir, image) + source, target = os.path.join(self.base_dir, image), os.path.join(self.target_dir, image) + + # XXX doing this DOESN'T improve perf at all (or something like 0.1%) + # if os.path.exists(target) and os.path.getsize(source) == os.path.getsize(target): + # print "Skiped %s since the file hasn't been modified based on file size" % source + # return "" + + shutil.copyfile(source, target) + print source, "->", target return "" def generate_thumbnail(self, image, gm_geometry):