Robert Bradshaw wrote: > On May 6, 2009, at 11:23 PM, Stefan Behnel wrote: > >> Robert Bradshaw wrote: >>> On May 6, 2009, at 1:08 PM, Carl Witty wrote: >>>> Yes, but you said that you only implement it within a single module >>>> (which is what I see in element.c); I'm saying that it should >>>> also be >>>> possible to implement across modules (just make tp_new functions >>>> non-static, add an extern declaration in the second module, and call >>>> the function directly). >>> Yes, I we could do this. We could also support exported cdef >>> functions this way, instead of the current function import mechanism. >>> (Or was there some reason it wasn't done this way in the first place? >> There are two cdef function export mechanisms: "public" and "api". The >> second is targeted towards calling functions between separate >> extension >> modules (through "__pyx_capi"), while "public" (and declaration in the >> module .pxd file IIRC) simply removes the name mangling and makes >> functions >> non-static for use in other C files linked into the same extension >> module. >> >> So this would mimic the "public" mechanism in a way, although it'd be >> better to do the normal name mangling for tp_new() even if we >> export it. > > Yes, I'm thinking of "api" functions, mangled and all, but without > the __pyx_capi object. Actually, I don't know if this would work, as > the .so files may not be loaded in the right order.
And by default, the .so files are loaded with RTLD_PRIVATE, not RTLD_GLOBAL, so that symbols in one isn't available in another. I think you'd have a hard time getting it to work reliably; but if you do it would be cool as it would speed up cross-Cython-module code (?). One could do a combination approach where __pyx_capi is available but a custom Cython classloader (like pyximport) would load the .so as RTLD_GLOBAL. A bit convoluted though, and I wonder whether it should be a priority... In the end, there are "inlineable" functions which are so small that the overhead matters, and "non-inlineable" which do so much anyway that it doesn't matter. The former can be put in inline __init__ code in pxd files, while the latter should be able to live with __pyx_capi. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
