Upper memory limit

Fernando Pérez fperez528 at yahoo.com
Tue May 14 17:00:59 EDT 2002


Siegfried Gonzi wrote:

> Fernando Pérez wrote:
> 
>> You may find it 'very readable (and often better in style than Numeric's
>> idiosyncrasy)' but in many cases the above is about the worst possible way
>> of dealing with a Numeric array you could come up with. What you call
>> 'Numeric's idiosyncrasy' has a very good reason for being the way it is:
>> when you work with Numeric arrays as single entities and apply functions to
>> them as a whole, you gain the _massive_ advantage of looping being done in
>> C instead of Python. This can make a difference of one or two orders of
>> magnitude in execution time.
>> 
>> I personally can't stand windows and consider Linux a zillion times better
>> as an environment for scientific computing, but in this particular case I
>> can't guarantee that your memory problems will go away in Linux.
> 
> 
> [It is clear that the erg.append() is not very effective; but in Python
> or Lisp I use another strategy for programming]. Note: the first 2
> function calls take only 20 minutes! Btw.: After 6 hours, my calculation
> on my laptop has just finished.

One strategy I use in similar problems is to operate on a pre-allocated 
Numeric array (using zeros()). That sidesteps all the calls to realloc() 
which can get very expensive quickly.

Plus, look into using weave (http://scipy.org) for the tight loops. A few 
lines of C can mean a factor of 20 or 30 in speedup.

Look at http://www-hep.colorado.edu/~fperez/python/python-c/ for some 
information and examples.

> Btw. I will prepare you a place in heaven if you can tell me whether
> there is an option to set a default path. For example, I have
> successfully installed Python in:
> 
> /home/gonzi/Python-2.2.1/...
> 
> and my Numeric-21.0 resides in:
> 
> /home/gonzi/Python-2.2.1/Numeric-21.0
> 
> 
> but after trying to install the Numeric stuff::
> 
> python setup.py install
> 
> 
> I get the error message:
> 
> creating /usr/local/lib/python2.2/site-packages/Numeric
> error: could not create
> '/usr/local/lib/python2.2/site-packages/Numeric': Permission denied
> 
> 
> I tried to use the --path=.... option but this does not work. How can I
> tell it to use my path and not a default directory?

First, make sure that you are finding the right python:

$ which python

should tell you which python runs when you type 'python'. Next, you can tell 
setup.py to put things where you want with the --home option:

python setup.py install --home=/your/path

Cheers,

f.



More information about the Python-list mailing list