I want to know how to reduce the run time of my program. Are using single line loops more effcient than multi line?
#is this more efficient
total_data = [[arr1[j][i] for j in range(3)]+ arr2[i][0] for i in range(10000)]
#instead of
total_data = []
for i in range(10000):
arr3 = []
a2 = arr2[i][0]
for j in range(3):
arr3.append(arr1[j][i])
total_data.append(arr3+a2)
Also, when calling a function, does using map save more time, instead of for loop?
#this
f1 = map(func1, var1, var2)
arr = map(func2, f2, var3, var4)
#instead of this
arr = []
for i in range(1000):
f1 = func1(var1(i), var2(i))
f2 = func2(f1(i))
arr.append(f2, var3, var4)
My data set is large and each function run time is also considerable, so I want to reduce the time as much as possible. I want to know fundamentally whether increasing lines in python for the same loop increases the time.