-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: pandas' import time #16764
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
Comments
do these in independent processes |
Oh, right - |
or better yet import numpy and matplotlib first |
We do attempt to import matplotlib at import time. We could delay that with something like diff --git a/pandas/plotting/__init__.py b/pandas/plotting/__init__.py
index c3cbedb0f..8f98e297e 100644
--- a/pandas/plotting/__init__.py
+++ b/pandas/plotting/__init__.py
@@ -4,12 +4,6 @@ Plotting api
# flake8: noqa
-try: # mpl optional
- from pandas.plotting import _converter
- _converter.register() # needs to override so set_xlim works with str/number
-except ImportError:
- pass
-
from pandas.plotting._misc import (scatter_matrix, radviz,
andrews_curves, bootstrap_plot,
parallel_coordinates, lag_plot,
diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py
index 391fa377f..9821c89c4 100644
--- a/pandas/plotting/_core.py
+++ b/pandas/plotting/_core.py
@@ -37,12 +37,7 @@ from pandas.plotting._tools import (_subplots, _flatten, table,
_get_xlim, _set_ticks_props,
format_date_labels)
-
-if _mpl_ge_1_5_0():
- # Compat with mp 1.5, which uses cycler.
- import cycler
- colors = mpl_stylesheet.pop('axes.color_cycle')
- mpl_stylesheet['axes.prop_cycle'] = cycler.cycler('color', colors)
+_registered = False
def _get_standard_kind(kind):
@@ -92,6 +87,7 @@ class MPLPlot(object):
secondary_y=False, colormap=None,
table=False, layout=None, **kwds):
+ self._setup()
self.data = data
self.by = by
@@ -175,6 +171,20 @@ class MPLPlot(object):
self._validate_color_args()
+ def _setup(self):
+ global _registered
+ if not _registered:
+ from pandas.plotting import _converter
+ _converter.register()
+
+ if _mpl_ge_1_5_0():
+ # Compat with mp 1.5, which uses cycler.
+ import cycler
+ colors = mpl_stylesheet.pop('axes.color_cycle')
+ mpl_stylesheet['axes.prop_cycle'] = cycler.cycler('color', colors)
+
+ _registered = True
+
def _validate_color_args(self):
if 'color' not in self.kwds and 'colors' in self.kwds:
warnings.warn(("'colors' is being deprecated. Please use 'color'" That covers all the |
Looks like |
Oh, sorry, I was thinking of |
I did a profile with https://github.com/cournape/import-profiler From a very quick skim:
Not huge, but those two would already remove ca 20% of the import time. However I don't see Full output:
|
Also see #7282, but seems like already more attention here. |
It's a bit different issue, this is in general about reducing import time, the other issue is about a specific case where the import takes many seconds (but also numpy takes seconds to import, so IMO it's not pandas specific issue) |
I wouldn't normally be concerned about this, as of it course it only happens once, but our import time has gotten quite long, to the point I notice it hanging my
ipython
startup.I don't have a good sense of what would be required to improve this, probably deferring more imports to be just in time?
on
0.20.2
- each import in a separate processBelow is a single process, importing deps first
The text was updated successfully, but these errors were encountered: