From: Michael Droettboom <mdroe@st...> - 2007-11-29 20:30:38
There are some Gtk-specific functions at the bottom of mlab.py. It
tries to "import gtk" and then will either define them or not.
On one of my recent profiling fests, I noticed that this "import gtk"
(if gtk is installed, and running with some non-Gtk backend) accounts
for between 1-2% of the total running time over all the examples in
backend_driver.py. Not a huge amount, but it seems like it might be a
good idea to avoid importing something as large as gtk unless we
actually need to.
We can either import gtk "on demand", when one of these gtk-related
functions is called, or perhaps better yet move this to another module,
that would only be imported when needed. In light of recent
pylab.py/mlab.py refactorings, are there any opinions on this?
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: John Hunter <jdh2358@gm...> - 2007-11-29 20:42:47
On Nov 29, 2007 2:30 PM, Michael Droettboom <mdroe@...> wrote:
> There are some Gtk-specific functions at the bottom of mlab.py. It
> tries to "import gtk" and then will either define them or not.
Ahh, I hadn't considered import time in the try/except block. In
light of this, we probably will want to put them in another module. I
was inclined to something like matplotlib.gui.gtktools, but tere is
an analogous problem with mlab.rec2excel which conditionally imports
pyExcelerator (you probably did not notice it in your timing since it
wasn't installed). Perhaps matplotlib.external or
matplotlib.optional as top-level packages for both (and related).
This will serve the dual purpose of cleaning mlab and making Jarrod's
job a bit easier when he decides what to bring over to scipy.