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 Shai
Recipients Shai, brett.cannon, hongweipeng, pitrou
Date 2019-08-27.06:42:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566888152.49.0.579188343833.issue37935@roundup.psfhosted.org>
In-reply-to
Content
From the docs (https://docs.python.org/3/library/os.html#os.scandir.close):

"This is called automatically when the iterator is exhausted or garbage collected, or when an error happens during iterating. However it is advisable to call it explicitly or use the with statement.".

The iterator is indeed closed properly, but the docs state that it's still advisable to close it explicitly, which is why I wrapped it in a with statement.

However, the more important change is that the iterator is no longer converted into a list, which should reduce the iterations from 2N to N, when N is the number of entries in the directory (one N when converting to list and another one when iterating it). This should enhance the performance of the functions that use scandir.
History
Date User Action Args
2019-08-27 06:42:32Shaisetrecipients: + Shai, brett.cannon, pitrou, hongweipeng
2019-08-27 06:42:32Shaisetmessageid: <1566888152.49.0.579188343833.issue37935@roundup.psfhosted.org>
2019-08-27 06:42:32Shailinkissue37935 messages
2019-08-27 06:42:32Shaicreate