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