[Numpy-discussion] Question about Optimization (Inline and Pyrex)

Bruce Southey bsouthey@gmail....
Tue Apr 17 13:11:20 CDT 2007


Hi,
You can find various suggestions to improve performance like Tim
Hochberg's list:

"""
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.

Bruce




On 4/17/07, Simon Berube <sberub@gmail.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.
>
> Regards,
>
> Simon Berube
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the Numpy-discussion mailing list