[Numpy-discussion] Surprising performance tweak in Cython

Anne Archibald peridot.faceted@gmail....
Mon Jun 23 01:03:06 CDT 2008

2008/6/23 Gael Varoquaux <gael.varoquaux@normalesup.org>:
> On Sun, Jun 22, 2008 at 06:39:21PM -1000, Eric Firing wrote:
>> 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.
> Indeed, I was looking for a forgotten type definition, but I forgotten to
> look for typos in the type definitions. As a results, the cython code is
> now of comparable speed to the weave.inline: cython=59ms and weave=62.5ms
> on my box.
> Thanks a lot, next time I'll now where to look.

One way to track down this kind of problem is to look at the C code
that's generated. Easier, I admit, with a little familiarity with C,
but in any case code working with python variables will be obtrusively
strewn with functions like "PyFoo"; efficient code will be mostly
devoid of underscores and the "Py" prefix.


More information about the Numpy-discussion mailing list