On Wed, Jul 14, 2010 at 4:03 AM, Sturla Molden <[email protected]> wrote: >> On Tue, Jul 13, 2010 at 10:30 PM, Kurt Smith <[email protected]> wrote: > >> as a minor note, blitz++ handles this with expression templates, > > Blitz++ do this just for arrays with fixed size at compile time. > > The gain from template meta-programming is almost amortized from better > C++ compilers. Today C++ compiler tend to produce better machine code than > anything else (C and Fortran included) on x86 and amd64. While when > blitz++ was written, they were slow bloatware generators that took a > 5x-10x performance hit compared with Fortran77. They don't do that > anymore. > > If you have Langtangen's book on "Python Scripting for Computational > Science", chapter 10.3 explains how to wrap NumPy arrays in a C++ class. > > C++ also support complex numbers in the class std::complex, and > std::vector works almost like a Python list. std::map can be used almost > like a dictionary. So yes, C++ should be preferred over C. But preferred > over Fortran 95? > > There are two issues I think: > > * C++ is very hard to use correctly, and can take 10 years to fully > master. I does not take that long to learn Fortran 95. > > * We have Python (or Cython) to do the non-numerical work. If we just want > to crunch numbers, there is nothing like Fortran. > > So what about Cython? > > In my experience, I always have to resort to Fortran or C++. Cython cannot > use NumPy arrays efficiently as function arguments. That is a big show > stopper.
Could you clarify? I suppose for very small arrays, there's the extra O(1) type-check/stride extraction overhead. Is there anything else? Of course there's always more room for improvement for the array type. > Cython therefore degenerate to C (working with pointers instead > of arrays), and we could just as well have written C, which is what we > want to avoid. So that leaves us with C++ (wrapped NumPy arrays) or > Fortran 95. Personally, I'd rather work with C than C++ or Fortan (and prefer Python/Cython to both), but that's a matter of preference. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
