Python dict.get's Default Value is Always Evaluated

This is a gotcha I ran across in some production code that is obvious in
retrospect. I was profiling the code to find places where we were
calling an_expensive_database_function and came across code like
this:

The original author probably assumed that if 'key' was present in the
kwargs dictionary an_expensive_database_function wouldn't be called;
that it would be short circuited in the same manner as Boolean
expressions. But since get is a function the arguments are always
evaluated on the way into the function. So in this case even if the
value of an_expensive_database_function was already present in the
kwargs dictionary the database function would be called again.