
Refer to os.py for the implementation of os.walk, posixmodule.c for the implementation of listdir and win32_stat (invoked by both isdir and getsize.) You can either use Anurag's solution, or try to call FindFirstFile/ FindNextFile directly and recursively (which should be comparable to the performance of a cygwin or other win32 port du -s some_directory.) That is 3x more system calls per file than Windows Explorer, plus memory allocation and manipulation overhead.


