[Numpy-discussion] Making a minimalist NumPy

David M. Cooke cookedm@physics.mcmaster...
Sun Nov 4 17:42:26 CST 2007

On Nov 4, 2007, at 15:51 , Benjamin M. Schwartz wrote:

> NumPy is included in the OLPC operating system, which is very  
> constrained in
> space.  Therefore, it would be nice to remove some subpackages to  
> save a few
> megabytes.  For example, the system does not include any Fortran  
> code or
> compiler, so f2py (3.6 MB) seems superfluous.  I also think the  
> distutils
> subpackage (1.9M) is probably not necessary.  Therefore, I have two  
> questions.
> 1. Which packages do you think are necessary to have a functioning  
> NumPy?
> 2. What is the easiest way to make (or get) a minimal NumPy  
> installation?  For
> example, would the scons/autoconf branch make this easier?

The *biggest* single optimisation for space that you could make is not  
to have both .pyc and .pyo files. AFAIK, the only difference between  
the two now is that .pyo files don't have asserts included. Testing on  
build 625 of the OLPC runnng in VMWare, that removes about 3MB from  
the numpy package right there (and even more when done globally --  
about 25MB.). [btw, the Python test/ directory would be another 14MB.]

After that,

1) remove f2py -- as you say, no Fortran, no need (2.2MB)
2) remove test directories "find . -name tests -type d -exec rm -rf  
{} ;' (1MB)
3) remove distutils (1MB)

Now, it's down to about 3.5 MB; there's not much more that can be done  
after that.

While I'm confident that removing the f2py and test directories can be  
done safely (by just removing the directories), I'm not so sure about  
numpy.distutils -- it really depends on what other software you're  
using. It could be trimmed a bit: the Fortran compiler descriptions in  
distutils/fcompiler/ could be removed, and system_info.py could be cut  
down. Although you can make up for the extra space it uses by removing  
Numeric (2MB).

|David M. Cooke              http://arbutus.physics.mcmaster.ca/dmc/

More information about the Numpy-discussion mailing list