From e7dfa26ce2d9e5aa51adad3964eff2cc72985d9c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Feb 2014 09:09:50 +0100 Subject: do not do unneccasary work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/comprehensive | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/comprehensive b/examples/comprehensive index e1c045e..26abc3c 100644 --- a/examples/comprehensive +++ b/examples/comprehensive @@ -120,6 +120,7 @@ monitor_controller = lambda : randr(*monitors) ''' +last_dayness = None def periodically(year, month, day, hour, minute, second, weekday, fade): ''' :(int, int, int, int, int, int, int, float?)?→void Place holder for periodically invoked function @@ -154,7 +155,12 @@ def periodically(year, month, day, hour, minute, second, weekday, fade): (*) Can be exceeded if the calendar system is changed, like in 1712-(02)Feb-30 (**) See https://en.wikipedia.org/wiki/Leap_second ''' + global last_dayness dayness = get_dayness() + if fade is None: + if dayness == last_dayness: + return + last_dayness = dayness # Help functions for colour interpolation interpol = lambda _day, _night : _day[m % len(_day)] * dayness + _night[m % len(_night)] * (1 - dayness) -- cgit v1.2.3-70-g09d2