Serhiy Storchaka <[email protected]> added the comment:
It is not so easy. There was reason why it was not done earlier. scandir()
wastes more limited resource than memory -- file descriptors. It should also be
properly closed and do not depend on the garbage collector.
Consider the example:
def traverse(path, visit):
for child in path.iterdir():
if child.is_dir():
traverse(path, visit)
else:
visit(child)
With your optimization it may fail with OSError: Too many open files.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39907>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com