[Numpy-discussion] minimal numpy ?
Robert
kxroberto@googlemail....
Sat May 16 05:23:23 CDT 2009
David Cournapeau wrote:
> Robert wrote:
>> for use in binary distribution where I need only basics and fast
>> startup/low memory footprint, I try to isolate the minimal ndarray
>> type and what I need..
>>
[..]
>
> I think you need at least umath to make this work: when doing import
> numpy.core.multiarray, you pull out the whole numpy (because import
> foo.bar induces import foo I believe), whereas import multiarray just
> imports the multiarray C extension.
>
> So my suggestion would be to modify numpy such as you can do import
> numpy after having removed most directories inside numpy. The big ones
> are distutils and f2py, which should already save 2.5 Mb and are not
> used at all in numpy itself. IIRC, the only problematic package is
> numpy.lib (we import numpy.lib in numpy.core IIRC).
>
Did like this - keeping a /numpy/core folder structure.
In attachment is a README-minimal-numpy.txt
Maybe thats interesting for many users / inclusion somewhere in
the docs.
Result is: some 300kB compressed.
And startup very fast.
Strange:
most imports in the package are relative - which is good for
(flat) repackaging. Just one absolutue "from numpy.core.multiarray
import ..." in a py file.
Yet the 2 remaining DLL's obviously contain absolute imports of
each other. Just because of that it is not possible to have the
"minimal numpy" in a separate package folder with other name
(without recompiling), but one needs to rename/remove the original
numpy from the PYTHONPATH :-(
Maybe the absolute imports could be removed out of the DLLs in
future. By #ifdef or so in the C code the newer Pythons also can
be forced to do precisely relative import.
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: README-minimal-numpy.txt
Url: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090516/344c0958/attachment.txt
More information about the Numpy-discussion
mailing list