This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients barneygale, pitrou, serhiy.storchaka, xtreak
Date 2020-03-09.12:32:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583757174.44.0.0872094649917.issue39907@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-09 12:32:54serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, xtreak, barneygale
2020-03-09 12:32:54serhiy.storchakasetmessageid: <1583757174.44.0.0872094649917.issue39907@roundup.psfhosted.org>
2020-03-09 12:32:54serhiy.storchakalinkissue39907 messages
2020-03-09 12:32:54serhiy.storchakacreate