![]() ![]() That is 3x more system calls per file than Windows Explorer, plus memory allocation and manipulation overhead. you then call getsize for each file returned by os.walk (which again calls GetFileAttributesEx).os.walk and os.listdir will perform additional memory allocation, string and array operations etc.os.walk then calls isdir for each file returned by os.listdir (which internally calls GetFileAttributesEx - or, prior to Win2k, a GetFileAttributes+ FindFirstFile combo) to redetermine whether to recurse or not.any additional system calls made from this point onward can only make you slower than Windows Explorer.os.walk first calls os.listdir (which internally calls FindFirstFile/ FindNextFile).Python is unfortunately not your friend in this case. Windows Explorer almost certainly uses FindFirstFile/ FindNextFile to both traverse the directory structure and collect size information (through lpFindFileData) in one pass, making what is essentially a single system call per file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |