[Numpy-discussion] Proposed Roadmap Overview

Nathaniel Smith njs@pobox....
Sun Feb 19 12:32:02 CST 2012

On Sun, Feb 19, 2012 at 4:13 PM, xavier.gnata@gmail.com
<xavier.gnata@gmail.com> wrote:
> I'm no sure. If you want to be able to write A=B+C+D; with decent
> performances, I think you have to use a lib based on expression templates.
> It would be great if C++ compilers could automatically optimize out
> spurious copies into temporaries.
> However, I don't think the compilers are smart enough to do so...not yet.

But isn't this all irrelevant to numpy? Numpy is basically a large
collection of bare inner loops, plus a bunch of dynamic dispatch
machinery to make sure that the right one gets called at the right
time. Since these are exposed directly to Python, there's really no
way for the compiler to optimize out spurious copies or anything like
that -- even a very smart fortran-esque static compiler can't optimize
complex expressions like A=B+C+D if they simply aren't present at
compile time. And I guess even less-fancy C compilers will still be
able to optimize simple ufunc loops pretty well. IIUC the important
thing for numpy speed is the code that works out at runtime whether
this particular array would benefit from a column-based or row-based
strategy, chooses the right buffer sizes, etc., which isn't really
something a compiler can help with.

-- Nathaniel

More information about the NumPy-Discussion mailing list