I have a python script that processes a large number of files.
For each file, the script goes line by line, searching for specific RegEx patters. If a pattern is found, the line is copied into the log file.
As sample input, I'm passing it a folder with 42 small files and 3 large files (~1500 lines each).
The scripts processes the first two large files very fast - it needs a few seconds for them. But when it reaches the third large file, it slows down, and it goes slower and slower.
In the middle of the third large file, it needs a whole second per line, and it keeps slowing down. If I don't stop it, the whole run takes an hour!
I added debugging code that prints out the line numbers - that's how I noticed that it keeps churning slower and slower, and it doesn't get stuck somewhere.
I have 20 years experience with c, and many other languages, but I'm a python beginner. What are steps that I can take to troubleshoot this script?