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.

classification
Title: Optimize pathlib.Path.iterdir()
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barneygale, zach.ware
Priority: normal Keywords: patch

Created on 2022-01-09 14:52 by barneygale, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30501 merged barneygale, 2022-01-09 15:10
Messages (2)
msg410154 - (view) Author: Barney Gale (barneygale) * Date: 2022-01-09 14:52
pathlib.Path.iterdir() contains the following code:

    if name in {'.', '..'}:
        # Yielding a path object for these makes little sense
        continue

This check is unnecessary as os.listdir() does not return entries for '.' or '..':

    os.listdir(path='.')
        Return a list containing the names of the entries in the
        directory given by path. The list is in arbitrary order, and
        does not include the special entries '.' and '..' even if they
        are present in the directory

See https://docs.python.org/3/library/os.html#os.listdir
msg411042 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2022-01-20 19:20
New changeset a1c88414926610a3527398a478c3e63c531dc742 by Barney Gale in branch 'main':
bpo-46316: optimize `pathlib.Path.iterdir()` (GH-30501)
https://github.com/python/cpython/commit/a1c88414926610a3527398a478c3e63c531dc742
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90474
2022-01-20 19:20:39zach.waresetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-20 19:20:08zach.waresetnosy: + zach.ware
messages: + msg411042
2022-01-09 15:10:58barneygalesetkeywords: + patch
stage: patch review
pull_requests: + pull_request28707
2022-01-09 14:52:52barneygalecreate