Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 352ad99

Browse files
committed
Undo change to iterdir()
1 parent 7a24a78 commit 352ad99

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

Lib/pathlib/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ def iterdir(self):
272272
The children are yielded in arbitrary order, and the
273273
special entries '.' and '..' are not included.
274274
"""
275-
with os.scandir(self) as entries:
276-
return iter([self._make_child_entry(entry) for entry in entries])
275+
return (self._make_child_relpath(name) for name in os.listdir(self))
277276

278277
def _scandir(self):
279278
return os.scandir(self)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Speed up :meth:`pathlib.Path.iterdir` and :meth:`~pathlib.Path.glob` by
2-
using :attr:`os.DirEntry.path` where possible.
1+
Speed up :meth:`pathlib.Path.glob` by using :attr:`os.DirEntry.path` where possible.

0 commit comments

Comments
 (0)