If (as it appears) context[get_varname()] is constant in the loop, maybe store it in a variable?