<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 5, 2015 at 11:26 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
For a long time, NumPy has supported two different ways of being compiled:<br>
<br>
"Separate compilation" mode: like most C projects, each .c file gets<br>
compiled to a .o file, and then the .o files get linked together to<br>
make a shared library. (This has been the default since 1.8.0.)<br>
<br>
"One file" mode: first concatenate all the .c files together to make<br>
one monster .c file, and then compile that .c file to make a shared<br>
library. (This was the default before 1.8.0.)<br>
<br>
Supporting these two different build modes creates a drag on<br>
development progress; in particular Stefan recently ran into this in<br>
this experiments with porting parts of the NumPy internals to Cython:<br>
  <a href="https://github.com/numpy/numpy/pull/6408" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/pull/6408</a><br>
(I suspect the particular problem he's running into can be fixed b/c<br>
so far he only has one .pyx file, but I also suspect that it will be<br>
impossible to support "one file" mode once we have multiple .pyx<br>
files.)<br>
<br>
There are some rumors that "one file" mode might be needed on some<br>
obscure platform somewhere, or that it might be necessary for<br>
statically linking numpy into the CPython executable, but we can't<br>
continue supporting things forever based only on rumors. If all we can<br>
get are rumors, then eventually we have to risk breaking things just<br>
to force anyone who cares to actually show up and explain what they<br>
need so we can support it properly :-).<br></blockquote><div><br></div><div>Assuming one of the rumour is related to some comments I made some time (years ?) earlier, the context was the ability to hide exported symbols. As you know, the issue is not to build extensions w/ multiple compilation units, but sharing functionalities between them without sharing them outside the extension. I am just reiterating that point so that we all discuss under the right context :)<br><br></div><div>I also agree the current situation is not sustainable -- as we discussed privately before, cythonizing numpy.core is made quite more complicated by this. I have myself quite a few issues w/ cythonizing the other parts of umath. I would also like to support the static link better than we do now (do we know some static link users we can contact to validate our approach ?)<br><br></div><div>Currently, what we have in numpy core is the following:<br><br></div><div>numpy.core.multiarray -> compilation units in numpy/core/src/multiarray/ + statically link npymath<br>numpy.core.umath -> compilation units in numpy/core/src/umath + statically link npymath/npysort + some shenanigans to use things in numpy.core.multiarray<br><br></div><div>I would suggest to have a more layered approach, to enable both 'normal' build and static build, without polluting the public namespace too much. This is an approach followed by most large libraries (e.g. MKL), and is fairly flexible. <br><br>Concretely, we could start by putting more common functionalities (aka the 'core' library) into its own static library. The API would be considered private to numpy (no stability guaranteed outside numpy), and every exported symbol from that library would be decorated appropriately to avoid potential clashes (e.g. '_npy_internal_').<br><br></div><div>FWIW, that has always been my intention to go toward this when I split up multiarray/umath into multiple .c files and extracted out npymath.<br><br></div><div>cheers,<br></div><div>David<br></div></div></div></div>