<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 8:47 PM, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr"><span class="">On Oct 8, 2015 06:30, "David Cournapeau" <<a href="mailto:cournape@gmail.com" target="_blank">cournape@gmail.com</a>> wrote:<br>
><br>
[...]<br>
><br></span><span class="">
> 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)</span></p>
<p dir="ltr">Check out Stéfan's branch -- it just uses regular linking to mix cython and C.</p></blockquote><div>I know, we worked on this together after all ;)</div><div><br></div><div>My suggested organisation is certainly not mandatory, I was not trying to claim otherwise, sorry if that was unclear.</div><div><br></div><div>At that point, I guess the consensus is that I have to prove my suggestion is useful. I will take a few more hours to submit a PR with the umath conversion (maybe merging w/ the work from Stéfan). I discovered on my flight back that you can call PyModule_Init multiple times for a given module, which is useful while we do the transition C->Cython for the module initialization (it is not documented as possible, so I would not to rely on it for long either).</div><div><br></div><div>David</div></div></div></div>