On Fri, May 8, 2009 at 7:08 AM, Brian Blais <[email protected]> wrote:
> On May 7, 2009, at 20:42 , Lisandro Dalcin wrote:
>
> Brian, in the Cython version, class Neuron, do this: instead of "def
> update(...)", please write "cpdef update(...)" and time your code
> again. If this make it faster (it should be near the C-struct
> version), please consider first removing your original "def update",
> and replace your "cdef _update()" by "cpdef update()".
>
> thanks, but this didn't change the time much at all (something like .5 ms
> out of 20ms).  I was following the example in the cython docs Early Binding
> for Speed section, but now I see it got updated to cpdef!


> I'll keep hacking away at it.  Perhaps I'll try a smaller example, to see
> the difference between lookups in classes and in structs, if that really is
> the issue.

I'm almos sure that's the issue :-)

Looking closer to your code, it seems the big offender is your
Connection class, as it attributes are bare "object" instances...

> Is there a better way to find speed bottlenecks than the "comment out and
> re-compile" method?  :)

In general, any time to cdef'ine something as "object", you are going
to pay the cost of Python attribute lookup via a dict... Try do get
rid of these definitions in favor of explicit types... In short, write
Cython code as if you were writing C++, where you have to explicitly
type everything.


> thanks,
>
> bb
>
> --
> Brian Blais
> [email protected]
> http://web.bryant.edu/~bblais
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to