Hi,
  I am drawing some barcharts and scatter plot and the speed for rendering is 
awful once you have
100 000 of dots. I ran python profiler which lead me to .startswith() calls and 
some for loops
which append do a list repeatedly. This parts could be still sped up I think 
but a first attempt
is here:


UNPATCHED 1.2.1

real    23m17.764s
user    13m25.880s
sys     3m37.180s


PATCHED:

real    6m59.831s
user    5m18.000s
sys     1m40.360s



The patches are simple and because I see elsewhere in the code list expansions 
I do not see any
problems with backwards compatibility (new new python language features are 
required).

Hope this helps,
Martin
--- lib/matplotlib/artist.py.ori	2013-08-09 13:46:22.000000000 +0200
+++ lib/matplotlib/artist.py	2013-08-09 13:46:36.000000000 +0200
@@ -827,7 +827,7 @@
 
         """
         names = [name for name in dir(self.o) if
-                 (name.startswith('set_') or name.startswith('get_'))
+                 (name[:4] in ['set_', 'get_'])
                  and callable(getattr(self.o, name))]
         aliases = {}
         for name in names:
--- lib/matplotlib/axes.py.ori	2013-08-09 13:46:16.000000000 +0200
+++ lib/matplotlib/axes.py	2013-08-09 13:46:44.000000000 +0200
@@ -4424,7 +4424,7 @@
         for handle in self._get_legend_handles(legend_handler_map):
             label = handle.get_label()
             #if (label is not None and label != '' and not label.startswith('_')):
-            if label and not label.startswith('_'):
+            if label and label[0] != '_':
                 handles.append(handle)
                 labels.append(label)
 
@@ -8135,7 +8135,7 @@
 
         patches = []
 
-        if histtype.startswith('bar'):
+        if histtype[:3] == 'bar':
             totwidth = np.diff(bins)
 
             if rwidth is not None:
@@ -8183,7 +8183,7 @@
                     bottom[:] = m
                 boffset += dw
 
-        elif histtype.startswith('step'):
+        elif histtype[:4] == 'step':
             # these define the perimeter of the polygon
             x = np.zeros( 4*len(bins)-3, np.float )
             y = np.zeros( 4*len(bins)-3, np.float )
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to