From 8fdecd56f5a28050f41c60fe87ac7367c99d2b4d Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Tue, 21 Feb 2023 21:29:59 -0800 Subject: [PATCH] Added batch_edit.py example, [skip ci] --- examples/batch_edit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/batch_edit.py b/examples/batch_edit.py index 8a1e30c0..5d1a3fdd 100644 --- a/examples/batch_edit.py +++ b/examples/batch_edit.py @@ -179,7 +179,10 @@ def set_photo_keywords_from_template( ps_photo.keywords = list(keywords) -@functools.lru_cache(maxsize=128) +# cache photoscript Photo object to avoid re-creating it for each photo +# maxsize=1 as this function is called repeatedly for each photo then +# the next photo is processed +@functools.lru_cache(maxsize=1) def photoscript_photo(photo: osxphotos.PhotoInfo) -> photoscript.Photo: """Return photoscript Photo object for photo""" return photoscript.Photo(photo.uuid)