[Numpy-discussion] Question about Optimization (Inline and Pyrex)
Tue Apr 17 13:11:20 CDT 2007
You can find various suggestions to improve performance like Tim
0. Think about your algorithm.
1. Vectorize your inner loop.
2. Eliminate temporaries
3. Ask for help
4. Recode in C.
5. Accept that your code will never be fast.
Step zero should probably be repeated after every other step ;)
The first item is very important because loop swapping and
factorization can really help. Item 1 is probably very important for
your 'long loops' . Also, Numpy may have a suitable function for some
of the calculations.
On 4/17/07, Simon Berube <email@example.com> wrote:
> I recently made the switch from Matlab to Python and am very
> interested in optimizing certain routines that I find too slow in
> python/numpy (long loops).
> I have looked and learned about the different methods used for such
> problems such as blitz, weave and pyrex but had a question for more
> experienced developpers.
> It appears that pyrex is the fastest of the bunch with weave very
> close behind but at the same time pyrex requires entirely different
> modules while weave can be inserted almost painlessly into existing
> code. Is the speed gain and usefulness of pyrex severely limited by
> the extra maintenance required y having separate "fast" routines from
> the rest of the code files?
> I am greatly interested in finding out what more experienced
> developers feel about these issues given that I may be completely off
> track and missing on a useful tool(pyrex) thinking weave is better
> than it actually is and I am quite frankly afraid of writing routines
> in one format and realizing later that it creates problems that I need
> to rewrite.
> I have tried searching for previous similar posts but could not find
> any. My apologies if this is a repeat or a severly dumb question.
> Simon Berube
> Numpy-discussion mailing list
More information about the Numpy-discussion