It took me over 3 minutes to loop over a 4gb text file, counting the number of lines, number of words and chars per line as I go. Is there a faster way to do this?

This is my code:

```
import time
import csv
import sys
csv.field_size_limit(sys.maxsize)
i=0
countwords={}
countchars={}
start=time.time()
with open("filename.txt", "r", encoding="utf-8") as file:
    for line in csv.reader(file, delimiter="\t"):
        i+=1
        countwords[i]=len(str(line).split())
        countchars[i]=len(str(line))
        if i%10000==0:
            print(i)
end=time.time()
if i>0:
    print(i)
    print(sum(countwords.values())/i)
    print(sum(countchars.values())/i)
    print(end-start)

```