I have a list of 4 million words in a txt file that I want to add to a list. I have two options:
l=[line for line in open(wordlist)]
or:
wordlist = file.readlines()
readlines() appears to be much faster, I'm guessing this is because the data is read into the memory in one go. The first option would be better for conserving memory because it reads one line at a time, is this true? Does readlines() use any type of buffer when copying? In general which is best to use?