cpython icon indicating copy to clipboard operation
cpython copied to clipboard

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

Open nh2 opened this issue 5 months ago • 1 comments

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:

  • #136059
  • Issue: gh-136059

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

nh2 avatar Jun 28 '25 08:06 nh2

All commit authors signed the Contributor License Agreement.

CLA signed

python-cla-bot[bot] avatar Jun 28 '25 08:06 python-cla-bot[bot]