[Tutor] Fastest way to iterate through a file

Robert Hicks sigzero at gmail.com
Tue Jun 26 00:20:30 CEST 2007


I have a script at work where I have a list of id numbers and I am doing a:

for line in ehFile:
     for id in line:
	
I am then going through that file and finding the line the id is on and 
printing the next line out. It takes a few seconds to see the output to 
the screen (the Perl version whips by) which got me to thinking I could 
be doing it faster (as I want to move it from Perl to Python).

If you need all the code I can post that tomorrow or I can try any ideas 
posted to this.

Thanks!

Robert



More information about the Tutor mailing list