I have some Python 2.7 code I\'m working on and it works great on any *nix type system. However, on windows the same section of code will have wildly different execution times.
I believe that it is due to range. Older version of python (2.X) has both range and xrange for this purpose. But xrange is efficient than range since xrange generates the list only when it is needed (i.e, it returns a generator) while range generates the entire list(hence inefficient, suppose you have a list from 1 to 100000)
So if your list size is increasing, the use of range could be the reason for your process being slowed down.
I don't see anything problematic. You have code that performs serial IO, which will block your process and possibly invoke the scheduler. If that happens, it will first give control to a different process and only when that one yield or exceeds its timeslice it will re-schedule your process.
The question for you is: What is the size of the scheduler timeslice of the systems you are running? I believe that this will give you an insight into what is happening.