[Numpy-discussion] How a transition to C++ could work

Adam Klein adam@lambdafoundry....
Sun Feb 19 09:45:36 CST 2012


On Feb 19, 2012, at 10:38 AM, Sturla Molden <sturla@molden.no> wrote:

 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.


Just to add, with respect to acceptable compilation times, a judicious
choice of C++ features is critical.

Sturla

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120219/04c510b2/attachment.html 


More information about the NumPy-Discussion mailing list