Reduce number of calls to os.stat