Improve extract performance via ignoring directory early during os.walk#694
Improve extract performance via ignoring directory early during os.walk#694stkao05 wants to merge 2 commits intopython-babel:masterfrom
Conversation
|
Real-life scenario I have experience When you are working with front-end, typically you would have a |
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
==========================================
- Coverage 90.97% 90.94% -0.04%
==========================================
Files 24 24
Lines 4176 4184 +8
==========================================
+ Hits 3799 3805 +6
- Misses 377 379 +2
Continue to review full report at Codecov.
|
|
Ping @akx |
babel/messages/extract.py
Outdated
| if dirname.startswith('.') or dirname.startswith('_'): | ||
| return False | ||
|
|
||
| absdir = os.path.join(root, dirname).replace(os.sep, '/') |
There was a problem hiding this comment.
Since the logic for ignoring filenames uses
filename = relpath(filepath, dirpath)
I think this should also use a relative path to the root. Otherwise this might end up ignoring paths that happen to contain an ignored fragment outside the relative root.
That is, if your project lives in /foobars/myproject/, and you've ignored *foobar* (as it has a special meaning within the myproject directory), and you invoke Babel from within /foobars/myproject/, this would ignore all files.
There was a problem hiding this comment.
Thanks for the feedbacks. Just applied your suggestion in 252323a
6ada6ee to
3a8587a
Compare
Currently, the extraction code will do an
os.walkto perform a deep file search. However, this file exploration could be very slow when there were directories that were deep and contain many files. Even if you have specified some directories to be ignored in the mapping file, theos.walkwould explore these directories.The PR improves the extract process performance via making sure to skip exploring those ignore directory early during
os.walk.