I need to use python to take N number of lines from large txt file. These files are basically tab delimited tables. My task has the following constraints:
Obvious improvement would be to use set() for your usedPositions variable - lookup will be faster, and since you need to handle up to 10^6 used positions, lookup time is not irrelevant.
Use xrange instead of range in a for loop. Allocating full list of integers doesn't seem necessary.