Skip to content

dynamically generate pyplot functions #9173

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
wants to merge 7 commits into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 9, 2017

PR Summary

Dynamically generate pyplot functions at import time. Functions define a proper __signature__ (via the funcsigs backport on Py2, which is a new dependency).

This PR does not appear to cause slowdown in the import time, as shown by

import sys
from time import perf_counter


for _ in range(10):
    start = perf_counter()
    import matplotlib.pyplot
    stop = perf_counter()
    print("elapsed: {}ms".format(int((stop - start) * 1000)))
    for mod_name in list(sys.modules):
        if mod_name.startswith("matplotlib"):
            del sys.modules[mod_name]

hold functionality was removed from the pyplot functions (it is scheduled for removal anyways) to avoid a needlessly complex implementation.

Remove boilerplate.py, which becomes unused.

Dynamically generate some more functions (plt.axis, plt.clf, etc.) which actually fall into the same pattern. Fix their docstrings accordingly.

[As a side note, some profiling suggests that right now the slowest step at import time is by far the calls to the various checkdep_* if you happen to have the ps.usedistiller or text.usetex rcparams set.]

PR Checklist

  • [OK] Has Pytest style unit tests (well, if the current test suite still pass)
  • [OK] Code is PEP 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] 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) (not clear if needed (hold also needs to be removed from the Axes class itself, this can be the object of a separate PR and documented there))
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor Author

anntzer commented Sep 9, 2017

I can't understand why funcsigs isn't getting installed on appveyor+py2 :/
edit: fixed

@anntzer anntzer mentioned this pull request Sep 10, 2017
6 tasks
@tacaswell tacaswell added this to the 2.2 (next next feature release) milestone Sep 17, 2017
@anntzer anntzer force-pushed the autogen-pyplot branch 2 times, most recently from a408d6e to a64c34e Compare November 10, 2017 19:04
@anntzer anntzer force-pushed the autogen-pyplot branch 2 times, most recently from 475bc46 to aed0979 Compare January 10, 2018 03:42
@tacaswell tacaswell modified the milestones: v2.2, v3.0 Jan 10, 2018
@anntzer
Copy link
Contributor Author

anntzer commented Apr 1, 2018

Replaced by #10918/#10934/... after discussion with @tacaswell.

@anntzer anntzer closed this Apr 1, 2018
@anntzer anntzer deleted the autogen-pyplot branch April 1, 2018 03:31
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.

2 participants