Wow, Python much faster than MatLab

sturlamolden sturlamolden at yahoo.no
Sun Dec 31 21:05:52 EST 2006


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.




More information about the Python-list mailing list