two enhancements for mpl 1.0

Hello,

may I suggest two enhancements for the upcoming matplotlib 1.0 release.

The first is related to bug #3011650 and fix r8379.
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib?view=revision&revision=8379

Texmanager.py, which is imported during the import of matplotlib, does call subprocess.Popen('dvipng'...) on every import. This can significantly add to the startup time of scripts. Given that most scripts don't use TeX, can the Popen() call be deferred to runtime? On my system (Python 2.6 for Windows, mpl 1.0rc1, MiKTeX 2.8) the 'backend_driver.py agg' tests are run about 8% (20s) faster with the following patch.

Index: lib/matplotlib/texmanager.py

texmanager_popen.diff (764 Bytes)

···

===================================================================
--- lib/matplotlib/texmanager.py (revision 8481)
+++ lib/matplotlib/texmanager.py (working copy)
@@ -91,7 +91,7 @@
      if not os.path.exists(texcache):
          os.mkdir(texcache)

- _dvipng_hack_alpha = dvipng_hack_alpha()
+ _dvipng_hack_alpha = None

      # mappable cache of
      rgba_arrayd = {}
@@ -516,6 +516,8 @@
              if rcParams['text.dvipnghack'] is not None:
                  hack = rcParams['text.dvipnghack']
              else:
+ if self._dvipng_hack_alpha is None:
+ self._dvipng_hack_alpha = dvipng_hack_alpha()
                  hack = self._dvipng_hack_alpha

              if hack:

The second enhancement, a quick fix for placing images of extreme aspect ratio, is to allow 'panchor' and 'fraction' arguments in colorbar().
http://sourceforge.net/tracker/?func=detail&aid=3016948&group_id=80706&atid=560723

Thanks,

Christoph

patch 1 is entirely reasonable and harmless so I committed it to trunk

JDH

···

On Fri, Jul 2, 2010 at 12:10 PM, Christoph Gohlke <cgohlke@...2143...> wrote:

Hello,

may I suggest two enhancements for the upcoming matplotlib 1.0 release.

The first is related to bug #3011650 and fix r8379.
matplotlib download | SourceForge.net

Texmanager.py, which is imported during the import of matplotlib, does call
subprocess.Popen('dvipng'...) on every import. This can significantly add to
the startup time of scripts. Given that most scripts don't use TeX, can the
Popen() call be deferred to runtime? On my system (Python 2.6 for Windows,
mpl 1.0rc1, MiKTeX 2.8) the 'backend_driver.py agg' tests are run about 8%
(20s) faster with the following patch.

Index: lib/matplotlib/texmanager.py

--- lib/matplotlib/texmanager.py (revision 8481)
+++ lib/matplotlib/texmanager.py (working copy)
@@ -91,7 +91,7 @@
if not os.path.exists(texcache):
os.mkdir(texcache)

- _dvipng_hack_alpha = dvipng_hack_alpha()
+ _dvipng_hack_alpha = None

\# mappable cache of
rgba\_arrayd = \{\}

@@ -516,6 +516,8 @@
if rcParams['text.dvipnghack'] is not None:
hack = rcParams['text.dvipnghack']
else:
+ if self._dvipng_hack_alpha is None:
+ self._dvipng_hack_alpha = dvipng_hack_alpha()
hack = self._dvipng_hack_alpha

        if hack:

I assigned this patch to me -- my only request is that you also update
the appropriate docstrings so it is clear that these keywords can be
passed in and what they mean.

···

On Fri, Jul 2, 2010 at 12:10 PM, Christoph Gohlke <cgohlke@...2143...> wrote:

The second enhancement, a quick fix for placing images of extreme aspect
ratio, is to allow 'panchor' and 'fraction' arguments in colorbar().
http://sourceforge.net/tracker/?func=detail&aid=3016948&group_id=80706&atid=560723