Skip to content

bpo-46316: optimize pathlib.Path.iterdir()#30501

Merged
zware merged 1 commit intopython:mainfrom
barneygale:bpo-46316-optimize-pathlib-path-iterdir
Jan 20, 2022
Merged

bpo-46316: optimize pathlib.Path.iterdir()#30501
zware merged 1 commit intopython:mainfrom
barneygale:bpo-46316-optimize-pathlib-path-iterdir

Conversation

@barneygale
Copy link
Copy Markdown
Contributor

@barneygale barneygale commented Jan 9, 2022

os.listdir() doesn't return entries for . or .., so we don't need to check for them here.

See https://docs.python.org/3/library/os.html#os.listdir

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.

https://bugs.python.org/issue46316

`os.listdir()` doesn't return entries for `.` or `..`, so we don't need to
check for them here.

See https://docs.python.org/3/library/os.html#os.listdir
Copy link
Copy Markdown
Member

@zware zware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; confirmed that both implementations of listdir explicitly elide . and .., and it doesn't look like self._accessor.listdir can be anything other than os.listdir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance or resource usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants