-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve extract performance via ignoring directory early during os.walk #694
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedbacks. Just applied your suggestion in 252323a
6ada6ee
to
3a8587a
Compare
Currently, the extraction code will do an
os.walk
to 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.walk
would explore these directories.The PR improves the extract process performance via making sure to skip exploring those ignore directory early during
os.walk
.