[Numpy-discussion] Surprising performance tweak in Cython
Sun Jun 22 23:39:21 CDT 2008
Another typo is the culprit:
In :timeit do_Mandelbrot_cython()
10 loops, best of 3: 53.8 ms per loop
In :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.
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,
> Numpy-discussion mailing list
More information about the Numpy-discussion