Klaas wrote: > C/C++ do not allocate extra arrays. What you posted _might_ bear a > small resemblance to what numpy might produce (if using vectorized > code, not explicit loop code). This is entirely unrelated to the > reasons why fortran can be faster than c.
Array libraries in C++ that use operator overloading produce intermediate arrays for the same reason as NumPy. There is a C++ library that are sometimes able to avoid intermediates (Blitz++), but it can only do so for small arrays for which bounds are known at compile time. Operator overloading is sometimes portrayed as required for scientific computing (e.g. in Java vs. C# flame wars), but the cure can be worse than the disease. C does not have operator overloading and is an entirely different case. You can of course avoid intermediates in C++ if you use C++ as C. You can do that in Python as well. -- http://mail.python.org/mailman/listinfo/python-list