Does knowledge diminish enjoyment?
October 15, 2025
I like to know how the sausage is made.
It is a truth universally acknowledged that watching movies is good and fun, but who could resist learning the fundamentals of filmmaking, curating a playlist of YouTube videos on color grading in Davinci Resolve, and having 20 issues of American Cinematographer delivered to their house? Nobody, that's who.
All this may come at a cost. I was watching Gilmore Girls with my girlfriend the other day when I noticed that the color grade between a shot of Lorelai and the reverse shot of Rory didn't match, making Lorelai appear slightly blue compared to Rory. As I paused the show to explain this to my girlfriend (she loves it when I do this), the realization dawned on me: my (extremely limited) knowledge of color grading has actually diminished my enjoyment of watching Gilmore Girls! From a 10 to a 9.5, but still.
This led to the following question: does learning about art actually make you more critical, thus diminishing your enjoyment?
This question bung banged around in my head for a while, when suddenly the answer came to me as I was watching Apocalpyse Now. Having learned about lighting, lenses, cameras... knowing how absurdly hard it is to shoot anything... it made me appreciate Apocalypse Now so much more. I have tried and failed many times to record a simple four-bar chord progression on guitar, and that experience has made listening to Snarky Puppy shredding Lingus even more jaw-dropping. And so on.
The conclusion I have come to for now is this: the more experience you have in an art form, the greater your dynamic range of enjoyment of the art. The highs will be higher, and the lows will be lower.
Timing how long a function takes in Python
October 8, 2025
Sometimes, in Python, it can be nice to know how long a function takes. Perhaps it's a function you're going to be calling lots of times and want to squeeze every last ounce of performance out of, or maybe, like me, you just want to know if you have time to go for a quick walk in the Utrecht University Botanical Gardens after running your code.
This is pretty trivial in Python! We can use the time module to subtract the time we started running the code from the time it finished:
import time
start_time = time.time()
calculate_complicated_things()
end_time = time.time()
duration = end_time - start_time:.2f
print(f"Calculating complicated things took {duration} seconds")
This works fine, but you have to remember the exact incantation and write it by hand each time. It would be nicer if we could abstract this away into a function, you know, like a programmer. Thankfully, we can, thanks to the magic of first-class functions! In Python (and most languages worth a damn), you can assign a function to a variable just like any other value, so we can pass in the function we want to call to our new time_function.
import time
def time_function(complicated_function):
start_time = time.time()
complicated_function()
end_time = time.time()
duration = end_time - start_time:.2f
print(f"This really complicated function took {duration} seconds")
We call it like this:
time_function(calculate_complicated_things)
But what if our long and complicated function takes arguments? In that case, we can pass those in to time_function as well, using positional (*args) and keyword arguments (**kwargs):
def time_function(func, *args, **kwargs):
start_time = time.time()
complicated_function(*args, **kwargs)
end_time = time.time()
duration = end_time - start_time:.2f
print(f"This really complicated function took {duration} seconds")
And now we call it like this:
time_function(calculate_complicated_function, first_argument, second_argument, keyword_argument=value)
And, just to be fancy, let's include the name of the function in the output, so we can see what took so damn long:
def time_function(func, *args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
print(f"Function '{func.__name__}' took {time.time() - start_time:.2f} seconds")
return result