-
Notifications
You must be signed in to change notification settings - Fork 115
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 radis import speed #309
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #309 +/- ##
===========================================
- Coverage 74.51% 74.31% -0.21%
===========================================
Files 121 122 +1
Lines 14806 14823 +17
===========================================
- Hits 11032 11015 -17
- Misses 3774 3808 +34 |
@erwanp Does the tool render different maps on different machines? I fetched this branch and ran tuna and I seemed to receive a different map? But there was significant improvement with this branch though. |
@@ -79,6 +77,9 @@ def fetch_astroquery( | |||
:py:attr:`astroquery.query.BaseQuery.cache_location` | |||
|
|||
""" | |||
from astropy import units as u |
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.
Basically import packages when necessary (?)
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.
Yes ! Imports within functions is harder to maintain so you don't want to do that for things you'll have to load anyway.
For astropy.units it didn't really work; as it's still imported at one point to check the inputs.
(saves 2s on import. check with code of radis#309)
Description
Improved RADIS import time by delaying the import of packages not necessarily used immediatly (or ever).
(also added a test for Cantera calculations on the default Travis test environment)
Tested with tuna
Before :
After:
So import is 75% faster (7s -> 4s) !
Delayed :
What's left (not for this PR)
Notice the time it takes Numba to compute Whiting's JIT.