On Jun 27, 2010, at 4:09 PM, Dan Stromberg wrote: > What's the size of the performance difference between Cython and a C > Extension Module? Obviously this depends on how well each is > written, and how many concessions to maintainability are made, but > just as rough estimates? > > If it's not a teensy difference, what is the main thing that > accounts for that difference? Is it perhaps the implicit memory > management?
The first thing to note is that Cython compiles down to C extension modules, so what you're asking is how Cython-generated modules compare to hand written ones. An analogy can be made with other compilers-- what is the performance of C vs. hand generated assembly? Obviously, this depends on the compiler and the human, but I would say in our case that, especially for sufficiently typed code, Cython usually emits the same code you would write in C, and the boilerplate code is more efficient than what a human would usually bother with. As with C vs. assembly, it is possible cut corners and beat the compiler in some cases, but this usually involves a high level of expertise, sacrificing portability/versatility, more easily shooting yourself in the foot, and a whole lot of timings of cases that the compilers never thought of. (Granted, Cython is not as mature as something like GCC, but it's a simpler problem and constantly improving.) Even then, most people I know of who use assembly start with C compiler output and tweak it from there (if necessary), which is worth doing with Cython. (Personally, I would never bother hand generating C until at least looking at what Cython gave me.) The average user, however, isn't going to do much better hand coding stuff in the vast majority of cases though. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
