Skip to content
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

Consider using scandir() instead of listdir() #12

Closed
adrianyorke opened this issue Jun 4, 2020 · 2 comments
Closed

Consider using scandir() instead of listdir() #12

adrianyorke opened this issue Jun 4, 2020 · 2 comments

Comments

@adrianyorke
Copy link

Firstly, thanks for this wonderful module. One improvement suggestion is to use scandir() rather than listdir().

You can read more about scandir() here:
https://www.python.org/dev/peps/pep-0471/

This text is particularly relevant:
"Like listdir, scandir calls the operating system's directory iteration system calls to get the names of the files in the given path, but it's different from listdir in two ways:

  1. Instead of returning bare filename strings, it returns lightweight DirEntry objects that hold the filename string and provide simple methods that allow access to the additional data the operating system may have returned.
  2. It returns a generator instead of a list, so that scandir acts as a true iterator instead of returning the full list immediately."
@njanakiev
Copy link
Owner

Thanks for the hint @adrianyorke! This was indeed something I had in mind! I've added it to the latest 0.4.0 release.

@adrianyorke
Copy link
Author

Thank you @njanakiev - great work!

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

No branches or pull requests

2 participants