Closed
Description
What is your issue?
Importing the xarray package takes a significant amount of time. For instance:
❯ time python -c "import xarray"
python -c "import xarray" 1.44s user 0.52s system 132% cpu 1.476 total
compared to others
❯ time python -c "import pandas"
python -c "import pandas" 0.45s user 0.35s system 177% cpu 0.447 total
❯ time python -c "import scipy"
python -c "import scipy" 0.29s user 0.23s system 297% cpu 0.175 total
❯ time python -c "import numpy"
python -c "import numpy" 0.29s user 0.43s system 313% cpu 0.229 total
❯ time python -c "import datetime"
python -c "import datetime" 0.05s user 0.00s system 99% cpu 0.051 total
I am obviously not surprised that importing xarray takes longer than importing Pandas, Numpy or the datetime module, but 1.5 s is something you clearly notice when it is done e.g. by a command-line application.
I inquired about import performance and found out about a lazy module loader proposal by the Scientific Python community. AFAIK SciPy uses a similar system to populate its namespaces without import time penalty. Would it be possible for xarray to use delayed imports when relevant?