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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ Reading directories
If the path is not a directory or otherwise inaccessible, :exc:`OSError` is
raised.

.. warning::
Copy link
Member

Choose a reason for hiding this comment

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

warning and even note directives attract too much attention. We usually avoid using them except in serious cases. Try also to shorten the text and don't describe the current behavior as a bug. For example, somethink like this:

"The contents of the directory are read in one go, but path objects are created during iteration. If you need to reduce latency for large directories, use :func:`os.scandir` instead."

Despite its name and being a generator, this function currently
does not stream directory entries: It reads all directory
entries into memory before yielding the first entry.
If you need constant-memory iteration across a large number of
directory entries, use :func:`os.scandir` instead.

.. method:: Path.glob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Expand Down
Loading
0