diff options
author | Jordan <me@jordan.im> | 2020-12-05 18:32:00 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2020-12-05 18:32:00 -0700 |
commit | 5e886308e60ac20ec7427d645370b7330ae88268 (patch) | |
tree | 287d338288c100a7014f6ec211705ef3afdaad86 | |
parent | f7055594aac17b2d5fd4e936a5924ece3e68cd63 (diff) | |
download | roka-5e886308e60ac20ec7427d645370b7330ae88268.tar.gz roka-5e886308e60ac20ec7427d645370b7330ae88268.zip |
use os.scandir() over os.walk(), better performance
-rw-r--r-- | lib/books.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/books.py b/lib/books.py index 86ab4b6..83d096d 100644 --- a/lib/books.py +++ b/lib/books.py @@ -31,10 +31,9 @@ class Books: ''' Return list of directories recursively discovered in :path: ''' - ret = list() - for root, dirs, _ in os.walk(path): - for d in dirs: - ret.append(os.path.join(root, d)) + s = os.scandir(path) + ret = [x.path for x in s if not x.name.startswith('.') and x.is_dir()] + s.close() return ret |