<p dir="ltr">On Oct 8, 2015 06:30, "David Cournapeau" <<a href="mailto:cournape@gmail.com">cournape@gmail.com</a>> wrote:<br>
><br>
[...]<br>
><br>
> Separating the pure C code into static lib is the simple way of achieving the same goal. Essentially, you write:<br>
><br>
> # implemented in npyinternal.a<br>
> _npy_internal_foo(....)<br>
><br>
> # implemented in merged_multiarray_umath.pyx<br>
> cdef PyArray_Foo(...):<br>
>     # use _npy_internal_foo()<br>
><br>
> then our merged_multiarray_umath.so is built by linking the .pyx and the npyinternal.a together. IOW, the static link is internal.<br>
><br>
> Going through npyinternal.a instead of just linking .o from pure C and Cython together gives us the following:<br>
><br>
>  1. the .a can just use normal linking strategies instead of the awkward capsule thing. Those are easy to get wrong when using cython as you may end up with multiple internal copies of the wrapped object inside capsule, causing hard to track bugs (this is what we wasted most of the time on w/ Stefan and Kurt during ds4ds)</p>
<p dir="ltr">Check out Stéfan's branch -- it just uses regular linking to mix cython and C. I know what you mean about the capsule thing, and I think we shouldn't use it at all. With a few tweaks, you can treat cython-generated .c files just like regular .c files (except for the main module file, which if we port it to cython then we just compile like a regular cython file).</p>
<p dir="ltr">-n</p>