On Apr 21, 2009, at 7:23 AM, Dag Sverre Seljebotn wrote:

> Jean-Francois Moulin wrote:
>> Great! Just tried it and it works fine!
>> I gain something like a tenfold factor in speed with respect to my
>> initial python code.
>>> From what I read I expect I should still gain quite a lot by
>> optimizing the calls to the Numpy functions.
>> Namely using the buffer notation defining the type of array I am  
>> using.
>> A question arises, should I also apply this notation in the  
>> definition
>> of my pointers? and if yes, how?
>>
>> so, I presently have statements like:
>> cdef int (*locate)(DelayLine, np.ndarray)
>>
>> and would write something like:
>>  cdef int (*locate)(DelayLine, np.ndarray[DTYPE_t,ndim=2])
>
> This is simply not supported with cdef functions. You need to do
>
> cdef int (*locate)(DelayLine, np.ndarray)
>
> and then inside the implementation of the function you assign to  
> it, you do
>
> cdef int (*locate)(DelayLine a, np.ndarray b)
>     cdef np.ndarray[DTYPE_t, ndim=2] b_buf = b
>     .... access b through b_buf ...

I may be missing something about your use cases, but is there any  
reason you're passing/storing function pointers all over the place  
instead of just calling cdef methods on a cdef class? That would  
probably make your code a lot cleaner and easier to understand (and  
write).

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to