Skip to content

bpo-39907: Improve performance of pathlib.Path.iterdir() by using os.scandir() under the hood #18865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Mar 9, 2020

Per PEP 471:

It returns a generator instead of a list, so that scandir acts as a true iterator instead of returning the full list immediately.

By using scandir() we avoid allocating a full list of directory children, and we don't need to worry about "." and ".." entries. Also simplifies the accessor interface a tiny bit.

https://bugs.python.org/issue39907

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@barneygale

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM, but you should add a NEWS entry using blurb tool. Install it with "python3 -m pip install --user blurb", than run "blurb".

@serhiy-storchaka, @pitrou: Would you mind to have a look as well?

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

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

+1, but need a NEWS entry (also need to wait for the CLA bit to be updated).

@serhiy-storchaka
Copy link
Member

There are reasons why it was not done earlier. I explained at the tracker.

@barneygale
Copy link
Contributor Author

Closing this PR per discussion on the tracker.

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

Successfully merging this pull request may close these issues.

6 participants