Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7c90a82a
Commit
7c90a82a
authored
Feb 11, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #25995: os.walk() no longer uses FDs proportional to the tree depth.
Different solution from 3.5.
parent
ffe96ae1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
Lib/os.py
Lib/os.py
+5
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/os.py
View file @
7c90a82a
...
...
@@ -356,6 +356,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
dirs
=
[]
nondirs
=
[]
walk_dirs
=
[]
# We may not have read permission for top, in which case we can't
# get a list of the files the directory contains. os.walk
...
...
@@ -414,7 +415,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
walk_into
=
not
is_symlink
if
walk_into
:
yield
from
walk
(
entry
.
path
,
topdown
,
onerror
,
followlinks
)
walk_dirs
.
append
(
entry
.
path
)
# Yield before recursion if going top down
if
topdown
:
...
...
@@ -431,6 +432,9 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
if
followlinks
or
not
islink
(
new_path
):
yield
from
walk
(
new_path
,
topdown
,
onerror
,
followlinks
)
else
:
# Recurse into sub-directories
for
new_path
in
walk_dirs
:
yield
from
walk
(
new_path
,
topdown
,
onerror
,
followlinks
)
# Yield after recursion if going bottom up
yield
top
,
dirs
,
nondirs
...
...
Misc/NEWS
View file @
7c90a82a
...
...
@@ -179,6 +179,8 @@ Core and Builtins
Library
-------
-
Issue
#
25995
:
os
.
walk
()
no
longer
uses
FDs
proportional
to
the
tree
depth
.
-
Issue
#
25994
:
Added
the
close
()
method
and
the
support
of
the
context
manager
protocol
for
the
os
.
scandir
()
iterator
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment