Resurrecting an old thread here....

On Tue, Mar 29, 2011 at 3:23 PM, David Kremer <da...@david-kremer.fr> wrote:

> > I would recommend running the import in the Python profiler to determine
> > where most of the time is going.  When I investigated this a few years
> > back, it was mainly due to loading the GUI toolkits, which are
> > understandably quite large.  You can avoid most of that by using the Agg
> > backend.  If you're using the Agg backend and still experiencing
> > slowness, it may be that load-up issues have crept back into matplotlib
> > since then -- but we need profiling data to figure out where and how.
>

Importing Matplotlib is very slow for me, too.  For a wxPython application
with embedded Matplotlib, I am getting "load" times of > 20 seconds when
"cold" importing matplotlib, with this (circa mid 2004) computer setup:
Windows XP, sp3, Intel Pentium, 1.70 Ghz, 1 GB RAM.

This is, by the way, an import well after Python and wxPython have already
been loaded into RAM, as it happens by a user action, so none of the time
involved here is due to loading Python or wxPython (they both load more
quickly--about 10 seconds to cold import them, my code, images, and some
other libraries).

First of all:  does that amount of time seem appropriate for that fast of a
system--or is that too long?  It definitely *feels* way too long from a
user perspective (for comparison Word or PowerPoint loads on this computer
in about 2.5 seconds).

Trying to improve it and following this old thread, I have switched to

matplotlib.use('Agg')

instead of

matplotlib.use('wxAgg')

as suggested to speed things up...but it is no faster.

I see, though, that I also have lines such as:

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg

Would the presence of these imports obviate the fact that I switched to
using the Agg instead of the wxAgg?  If so, is there any way to use
something faster here (I suspect not but thought I'd ask).

Also, what else should I consider doing to reduce the import time
significantly?  (I have to learn how to use the profiler, so I haven't done
that yet).

Thanks,
Che

 >
> > Mike
>
> Thank you a lot for your answer.
>
> I noticed than _matplotlib.pyplot_ is longer to be imported the first time
> than
> if it has already been imported previously (maybe things are already
> loaded in
> ram memory), and we don't need to fetch it from the hard drive thanks to
> the
> kernel.
>
> As far I see, the function calls are the same for the two logs I obtained,
> except than the first took 6s instead of 1.4s.
>
>
>
>
> The two logs have been obtained using :
> <code>
> python -m cProfile temp.py
> </code>
>
> where temp.py consist of two lines :
>
> <code>
> #!/usr/bin/env python2
>
> import matplotlib.pyplot
> </code>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Xperia(TM) PLAY
> It's a major breakthrough. An authentic gaming
> smartphone on the nation's most reliable network.
> And it wants your games.
> http://p.sf.net/sfu/verizon-sfdev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to