Skip to content

Commit

Permalink
use scandir() in find_commands.py to avoid stat() calls (#13071)
Browse files Browse the repository at this point in the history
  • Loading branch information
dholth committed Sep 11, 2023
1 parent a9b1838 commit 34c6746
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
8 changes: 3 additions & 5 deletions conda/cli/find_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ def find_commands(include_others=True):
for dir_path in dir_paths:
if not isdir(dir_path):
continue
for fn in os.listdir(dir_path):
if not isfile(join(dir_path, fn)):
continue
m = pat.match(fn)
if m:
for entry in os.scandir(dir_path):
m = pat.match(entry.name)
if m and entry.is_file():
res.add(m.group(1))
return tuple(sorted(res))
20 changes: 20 additions & 0 deletions news/find-commands-scandir
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* Use `os.scandir()` to find conda subcommands without `stat()` overhead.
(#13067)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit 34c6746

Please sign in to comment.