Delay import by TomAugspurger · Pull Request #17710 · pandas-dev/pandas (original) (raw)
Closes #16764
Improves performance by delaying the import of matplotlib, s3fs, pytest, and openpyxl.
Also removes our old MPL style sheet. The option was deprecated and removed, but the stylesheet hung around.
Master:
In [1]: %time import numpy
CPU times: user 36.3 ms, sys: 13.2 ms, total: 49.5 ms
Wall time: 68.4 ms
In [2]: %time import pandas
CPU times: user 306 ms, sys: 52.2 ms, total: 358 ms
Wall time: 392 ms
head:
In [1]: %time import numpy
CPU times: user 37.7 ms, sys: 12.4 ms, total: 50 ms
Wall time: 69 ms
In [2]: %time import pandas
CPU times: user 166 ms, sys: 40.9 ms, total: 207 ms
Wall time: 245 ms
I can shave off more by hardcoding pandas.__version__
. Maybe that's worthwhile for releases?
In [2]: %time import pandas
CPU times: user 133 ms, sys: 30 ms, total: 163 ms
Wall time: 173 ms