Skip to content
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

ENH: load plotting entry point only when necessary #41492

Closed
TLouf opened this issue May 15, 2021 · 1 comment · Fixed by #41503
Closed

ENH: load plotting entry point only when necessary #41492

TLouf opened this issue May 15, 2021 · 1 comment · Fixed by #41503
Labels
Compat pandas objects compatability with Numpy or Python functions Enhancement Performance Memory or execution speed performance Visualization plotting
Milestone

Comments

@TLouf
Copy link
Contributor

TLouf commented May 15, 2021

Is your feature request related to a problem?

All installed plotting backends are loaded on the first DataFrame.plot call of a kernel, resulting in a potentially unnecessary module loading time, although quite minor, as it's only done on the very first call. However, if the number of pluggable backends out there increases in the future, this could become a real nuisance for users who installed many of them in their environment.

Describe the solution you'd like

In pandas.plotting._core._find_backend, entry_point.load() should only be done for the solicited backend. This is straightforward to implement, I could write the PR myself.

API breaking implications

None as far as I know.

Describe alternatives you've considered

Additional context

With just hvPlot installed, the following

for entry_point in pkg_resources.iter_entry_points("pandas_plotting_backends"):
        if entry_point.name == "matplotlib":
            # matplotlib is an optional dependency. When
            # missing, this would raise.
            continue
        entry_point.load()

takes ~2s , while

for entry_point in pkg_resources.iter_entry_points("pandas_plotting_backends"):
        if entry_point.name == "matplotlib":
            # matplotlib is an optional dependency. When
            # missing, this would raise.
            continue

takes a few ms. As one would expect, entry_point.load() is the slowest part to execute by far.

@TLouf TLouf added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels May 15, 2021
@mzeitlin11
Copy link
Member

Thanks for the investigation @TLouf! That sounds reasonable to me, I think a PR to do this would be welcome.

@mzeitlin11 mzeitlin11 added Compat pandas objects compatability with Numpy or Python functions Performance Memory or execution speed performance Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 16, 2021
@jreback jreback added this to the 1.3 milestone Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Enhancement Performance Memory or execution speed performance Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants