From a8dd5eabb9dfc70f6a039084962d3e7831ab99f7 Mon Sep 17 00:00:00 2001 From: barneygale Date: Sun, 9 Jan 2022 02:21:03 +0000 Subject: [PATCH] bpo-46148: optimize `pathlib.Path.iterdir()` `os.listdir()` doesn't return entries for `.` or `..`, so we don't need to check for them here. --- Lib/pathlib.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Lib/pathlib.py b/Lib/pathlib.py index f1a33178e2958ba..04b321b9ccf1668 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -1013,9 +1013,6 @@ def iterdir(self): result for the special paths '.' and '..'. """ for name in self._accessor.listdir(self): - if name in {'.', '..'}: - # Yielding a path object for these makes little sense - continue yield self._make_child_relpath(name) def glob(self, pattern):