What is faster: Reading the same value from a list multiple times or saving the value to a new variable? My code looks something like this:
if list[0] > foo:
return list[0], list[0] + bar
Should I define l0 = list[0]
to avoid reading the list three times? Or is this inefficient because of memory allocation and garbage collection for the l0
variable?