SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] Performance and dates

From: Steve C. <ste...@ya...> - 2004年12月12日 15:04:50
I've been doing some profiling using
'hotshotmain.py simple_plot.py -dAgg >/tmp/hs-out 2>&1'
(with the Tools/scripts/hotshotmain.py script from the Python src
distribution)
I looked at the output and noticed that the pytz module takes up a fair
amount of the time. Which is a bit unexpected for simple_plot.py which
does not have any dates!
I commented out the 'dates' imports in pylab.py and axes.py and
performance increased 13%. It seemed strange for an import to have such
a large effect, but when I looked at dates.py I saw that it executes
code - it calls timezone() 9 times - a function which does further
imports which read in a lot of data.
If I restore the 'dates' imports and just comment out the 9 timezone()
calls in dates.py the speedup is 11% and it saves around 3,000 function
calls!
I suggest
- for optional modules (like dates), only import them when they are
required (when the plot actually has a date)
- for all modules try to minimise the amount of code that will execute
upon import, especially function calls.
What do you think?
Steve

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /