import functools, time, datetime @functools.lru_cache() def getCurrentTime(): # This nondeterministic function returns different values each time # it's called. return datetime.datetime.now() @functools.lru_cache() def printMessage(): # This function displays a message on the screen as a side effect. print('Hello, world!') print('Getting the current time twice:') print(getCurrentTime()) print('Waiting two seconds...') time.sleep(2) print(getCurrentTime()) print() print('Displaying a message twice:') printMessage() printMessage()