It is now possible (in cython-devel) to have inline cdef functions in 
pxd files. I.e. in mymod.pxd you can write

cdef inline int my_sum(int a, int b): return a + b

Only functions at the top level in pxd file are supported, and it must 
have the "inline" modifier, and must *not* have "api" or "public" modifiers.

Note: The implementation of the function is *copied* to every pyx-file 
using the pxd file.

(Coding it went surprisingly smooth, was primarily about letting it 
through the parser...please try to break it :-) ). The solution is a 
little hacky (added special case in Entry), but then I know I don't 
break something else.

Patches for numpy.pxd utilising this very welcome, I won't have time for 
that myself for some time.

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

Reply via email to