os.walk very slow, any way to optimise?
Yes: use Python 3.5 (which is still currently a RC, but should be out momentarily). In Python 3.5, os.walk was rewritten to be more efficient. This work done as part of PEP 471. Extracted from the PEP: Python’s built-in os.walk() is significantly slower than it needs to be, because — in addition to calling os.listdir() … Read more