Skip to content

Slower Imports? #3794

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

Closed
chebee7i opened this issue Nov 14, 2014 · 6 comments
Closed

Slower Imports? #3794

chebee7i opened this issue Nov 14, 2014 · 6 comments

Comments

@chebee7i
Copy link
Contributor

Previously I was running 1.3.1 and this was a typical load time:

$ time python -c "import matplotlib;print matplotlib.__version__"
1.3.1

real    0m0.158s
user    0m0.089s
sys     0m0.061s

$ time python -c "import matplotlib;import matplotlib.pyplot as plt;print matplotlib.__version__"
1.3.1

real    0m0.271s
user    0m0.185s
sys     0m0.078s

After upgrading to 1.4.2, I'm now getting something like:

$ time python -c "import matplotlib;print matplotlib.__version__"
1.4.2

real    0m0.142s
user    0m0.085s
sys 0m0.058s

$ time python -c "import matplotlib;import matplotlib.pyplot as plt;print matplotlib.__version__"
1.4.2

real    0m3.051s
user    0m2.899s
sys 0m0.152s

$ time python -c "import matplotlib;import matplotlib.pyplot as plt;print matplotlib.__version__"
1.4.2

real    0m3.106s
user    0m2.905s
sys 0m0.198s

Any ideas on why it is so much slower?

@chebee7i
Copy link
Contributor Author

Not sure what happened. I reinstalled and the issue went away.

@pelson
Copy link
Member

pelson commented Nov 17, 2014

For the record, it may have been that the py files hadn't been compiled, and therefore Python had to do work to create the pyc files each time (especially relevant if you installed to somewhere where you don't normally have write permission). Running a python -v can sometimes give this away.

@chebee7i
Copy link
Contributor Author

Good point. In this case, missing pyc files were not the issue. I had checked that they existed (in the virtualenv within my home directory). The slow times persisted after many consecutive runs as well. This was a pip install -e within the git repo.

@mspacek
Copy link
Contributor

mspacek commented Aug 26, 2015

I had the same problem. .pyc files weren't the issue. The solution is documented here:

http://stackoverflow.com/questions/26421364/extremely-slow-import-of-matplotlib-afm

All it required was deleting ~/.cache/matplotlib.

@pelson
Copy link
Member

pelson commented Aug 26, 2015

All it required was deleting ~/.cache/matplotlib.

Thanks @mspacek. I think we should fix this - it is a wart which can be fixed without major hassle (i.e. we should version the cache).

@mspacek - would you mind opening an issue to do that?

@mspacek
Copy link
Contributor

mspacek commented Aug 26, 2015

Done. #4993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants