Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(80982)

#28564: shutil.rmtree is inefficient due to listdir() instead of scandir()

Can't Edit
Can't Publish+Mail
Start Review
Created:
2 years, 5 months ago by public
Modified:
2 years, 4 months ago
Reviewers:
shadowranger+python, storchaka+cpython
CC:
AntoinePitrou, nh2_deditus.de, storchaka, Josh.R, xiang.zhang, public_enkore.de
Visibility:
Public.

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/shutil.py View 3 chunks +16 lines, -13 lines 2 comments Download
Lib/test/test_shutil.py View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 2
Josh.R
No need for os.path.join (really no need for fullname either) https://bugs.python.org/review/28564/diff/19085/Lib/shutil.py File Lib/shutil.py (right): https://bugs.python.org/review/28564/diff/19085/Lib/shutil.py#newcode399 ...
2 years, 5 months ago #1
storchaka
2 years, 4 months ago #2
http://bugs.python.org/review/28564/diff/19085/Lib/shutil.py
File Lib/shutil.py (right):

http://bugs.python.org/review/28564/diff/19085/Lib/shutil.py#newcode399
Lib/shutil.py:399: fullname = os.path.join(path, entry.name)
On 2016/11/09 03:55:38, josh.rosenberg wrote:
> Isn't this what entry.path is for? Either:
> 
> fullname = entry.path
> 
> or just skip fullname variable completely and sub in entry.path (entry.path is
a
> cached value on the DirEntry, so only advantage to saving to fullname is
> avoiding LOAD_ATTR if we use it many times).

When os.scandir() is called with a file descriptor, entry.path is the same as
entry.name (scandir doesn't know the path of the parent directory). See
issue25996.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+