Python 3: How to compare two big files fastest? Python 3: How to compare two big files fastest? json json

Python 3: How to compare two big files fastest?


looking up an item in a list takes O(n) time. If you use a dict or a set you can improve it to O(1).

shortest modification you can do is :

linesB = []for line in open('E:/Small_file.txt'):    line = json.loads(line)    linesB.append(hash(line['uid']))linesB = set(linesB)

or to do it right

linesB = set()for line in open('E:/Small_file.txt'):    line = json.loads(line)    linesB.add(hash(line['uid']))