diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-30 06:12:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 06:12:31 (GMT) |
commit | ea720fe7e99d68924deab38de955fe97f87e2b29 (patch) | |
tree | a5996c9c8577f8824876575c8dcbf912d86226bc /Doc/library/os.rst | |
parent | 0a58f72762353768c7d26412e627ff196aac6c4e (diff) | |
download | cpython-ea720fe7e99d68924deab38de955fe97f87e2b29.zip cpython-ea720fe7e99d68924deab38de955fe97f87e2b29.tar.gz cpython-ea720fe7e99d68924deab38de955fe97f87e2b29.tar.bz2 |
bpo-25996: Added support of file descriptors in os.scandir() on Unix. (#502)
os.fwalk() is sped up by 2 times by using os.scandir().
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r-- | Doc/library/os.rst | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 69dd5c4..071d158 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -2029,6 +2029,9 @@ features: attributes of each :class:`os.DirEntry` will be ``bytes``; in all other circumstances, they will be of type ``str``. + This function can also support :ref:`specifying a file descriptor + <path_fd>`; the file descriptor must refer to a directory. + The :func:`scandir` iterator supports the :term:`context manager` protocol and has the following method: @@ -2075,6 +2078,9 @@ features: The function accepts a :term:`path-like object`. + .. versionchanged:: 3.7 + Added support for :ref:`file descriptors <path_fd>` on Unix. + .. class:: DirEntry @@ -2114,7 +2120,9 @@ features: The entry's full path name: equivalent to ``os.path.join(scandir_path, entry.name)`` where *scandir_path* is the :func:`scandir` *path* argument. The path is only absolute if the :func:`scandir` *path* - argument was absolute. + argument was absolute. If the :func:`scandir` *path* + argument was a :ref:`file descriptor <path_fd>`, the :attr:`path` + attribute is the same as the :attr:`name` attribute. The :attr:`path` attribute will be ``bytes`` if the :func:`scandir` *path* argument is of type ``bytes`` and ``str`` otherwise. Use |