[Numpy-discussion] Surprising performance tweak in Cython

Eric Firing efiring@hawaii....
Sun Jun 22 23:39:21 CDT 2008


Gael,

Another typo is the culprit:

In [2]:timeit do_Mandelbrot_cython()
10 loops, best of 3: 53.8 ms per loop

In [3]:timeit do_Mandelbrot_cython2()
10 loops, best of 3: 54 ms per loop

This is after I put the underscore in the x_buffer declaration in 
do_Mandlebrot_cython2.  As it was, with no underscore, x_buffer was 
being treated as a python double.

With the typo fixed, the versions are virtually identical, with perhaps 
a slight edge for the non-inlined version.  This suggests to me that the 
compiler is smarter than we are.

Eric




Gael Varoquaux wrote:
> On Sun, Jun 22, 2008 at 05:02:38PM -1000, Eric Firing wrote:
>> The line above looks like a typo, and does not match your inline 
>> version.  Could that be making the difference?
> 
> Thank you Eric! It was indeed a typo (the plot is nicer with the typo,
> surprising, but that also explains why it didn't look exactly like the
> weave version).
> 
> That doesn't explain the performance, however, as with the typo
> corrected, the non-inlined version goes a bit faster: 110ms compared to
> 126ms. weave.inline is 62.5ms, surprisingly. Trying to understand the
> difference between weave.inline and cython lead me to inlining, and to
> the surprising result.
> 
> Thanks for your input,
> 
> Gaël
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list