I have the following code block in my program to read data from a large text file:
sets = []
for line in open(file, "r"):
sets.append(line.split())
I do not want to change the values ββin the lists. Since tuples are simpler in memory and processor, should I do the following instead?
sets = []
for line in open(file, "r"):
sets.append(tuple(line.split()))
Or just use lists because the data is homogeneous? If tuples are better, I can go overboard and do this:
sets = tuple(sets)
source
share