Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cleanup imports. #9938

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

Merged
merged 2 commits into from
Dec 29, 2017
Merged

Cleanup imports. #9938

merged 2 commits into from
Dec 29, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 5, 2017

PR Summary

Same as #9929, but for the lib itself: remove unused imports and sort/group some remaining imports.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer force-pushed the more-unused-imports branch 6 times, most recently from 25e008a to ec9cc33 Compare December 5, 2017 22:45
@tacaswell
Copy link
Member

Are there any benefits to this other than a bit of organization?

@tacaswell tacaswell added this to the v2.2 milestone Dec 5, 2017
@anntzer
Copy link
Contributor Author

anntzer commented Dec 5, 2017

Cutting down on pyflakes output...

@dopplershift
Copy link
Contributor

Removing unused imports could improve matplotlib's import time and memory usage. I'm not saying necessarily significantly, but I'll take what I can get for free. 😁

@jklymak
Copy link
Member

jklymak commented Dec 6, 2017

PEP 8 doesn't like animation.py

@tacaswell
Copy link
Member

It only helps if they are thing that would not be imported other wise. If things are already in sys.modules the import is basically free.

@anntzer anntzer force-pushed the more-unused-imports branch from ec9cc33 to bf3416c Compare December 6, 2017 00:38
@anntzer
Copy link
Contributor Author

anntzer commented Dec 6, 2017

Note that I never claimed this was for performance :p
PEP8 should be appeased now...

@tacaswell
Copy link
Member

I think we explicitly do not check this bit of pep8, if we are going to do this travis should enforce it.

The dark side of 'discover-the-api-via-tab-complete' is that users will have found and used some of those un-used imports so I expect this to break some user code. It should get some level of mention in the API changes docs.

@anntzer
Copy link
Contributor Author

anntzer commented Dec 6, 2017

Not saying that this PR fixes pep8; rather, pep8 was unhappy because it wanted conditional imports (vs Python version) to be at the bottom of the import list.
Added api changes note.

@anntzer anntzer force-pushed the more-unused-imports branch from bf3416c to b2dae53 Compare December 6, 2017 17:37
@dopplershift
Copy link
Contributor

@tacaswell I agree...that's why I said "could". 😁 Also, the unused import adds to the module's globals dict (not to mention takes a few instructions to execute), so that's technically more memory usage (and CPU). I'm not saying it's significant, but it's a "free" fix to not ask for things you don't use.

@anntzer anntzer force-pushed the more-unused-imports branch from b2dae53 to bf67b92 Compare December 26, 2017 22:25
@anntzer
Copy link
Contributor Author

anntzer commented Dec 28, 2017

grouped some more imports (in a separate commit)

@anntzer anntzer force-pushed the more-unused-imports branch from 85b35f6 to 23bd9df Compare December 28, 2017 22:04
@efiring efiring merged commit 64874e5 into matplotlib:master Dec 29, 2017
@anntzer anntzer deleted the more-unused-imports branch December 29, 2017 02:48
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
@anntzer anntzer mentioned this pull request Feb 17, 2018
6 tasks
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

Successfully merging this pull request may close these issues.

7 participants