[issue28564] shutil.rmtree is inefficient due to listdir() instead of scandir()
Marian Beermann
report at bugs.python.org
Mon Oct 31 13:40:23 EDT 2016
Marian Beermann added the comment:
The main issue on *nix is more likely that by using listdir you get directory order, while what you really need is inode ordering. scandir allows for that, since you get the inode from the DirEntry with no extra syscalls - especially without an open() or stat().
Other optimizations are also possible. For example opening the directory and using unlinkat() would likely shave off a bit of CPU. But the dominating factor here is likely the bad access pattern.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28564>
_______________________________________
More information about the Python-bugs-list
mailing list