Den 19.02.2012 10:52, skrev Mark Wiebe:
C++ removes some of this advantage -- now there is extra code
generated by
the compiler to handle constructors, destructors, operators etc
which can
make a material difference to fast inner loops. So you end up just
writing
"C-style" anyway.
This is in fact not true, and writing in C++ style can often produce
faster code. A classic example of this is C qsort vs C++ std::sort.
You may be thinking of using virtual functions in a class hierarchy,
where a tradeoff between performance and run-time polymorphism is
being done. Emulating the functionality that virtual functions provide
in C will give similar performance characteristics as the C++ language
feature itself.
I agree with Mark here. C++ usually produces the faster code. C++ has
abstractions that makes it easier to write more efficient code. C++
provides more and better information to the compiler (e.g. strict
aliasing rules). C++ compilers are also getting insanely good at
optimisation, usually better than C compilers. But C++ also makes it
easy to write sluggish bloatware, so the effect on performance is not
predictable.
Sturla
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion