8000 gh-136059: docs: pathlib: Mention that iterdir() is surprisingly not streaming by nh2 · Pull Request #136060 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-136059: docs: pathlib: Mention that iterdir() is surprisingly not streaming #136060

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nh2
Copy link
@nh2 nh2 commented Jun 28, 2025

This undocumented gotcha can cause excessive memory usage when "iterating" over very large directories.

This is because iterdir() does

entries = list(scandir_it)

Fixing (if at all desired) will likel need least significant amounts of discussion and testing, so first document the behaviour.

See:


📚 Documentation preview 📚: https://cpython-previews--136060.org.readthedocs.build/

This undocumented gotcha can cause excessive memory usage
when "iterating" over very large directories.

This is because iterdir() does

    entries = list(scandir_it)

Fixing (if at all desired) will likel need least significant amounts of
discussion and testing, so first document the behaviour.
@python-cla-bot
Copy link
python-cla-bot bot commented Jun 28, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant
0