list math for version 1.5.2 without Numeric

Kragen Sitaker kragen at
Thu Nov 29 00:06:21 CET 2001

joost_jacob at (J.Jacob) writes:
> List comprehension in the later Python versions is fun but i need to
> get this piece of code to run as quickly as possible on Python version
> 1.5.2 and no NumPy available (not allowed to install extra things on
> the computers here alas).

"install"?  What exactly aren't you allowed to do?  Put things in
/usr/local?  Use up a lot of disk space?  Leave stuff in the
filesystem overnight?  Write things to the filesystem at all?

I wonder if you could write a C module to do the job; it would
probably run a lot quicker, and it would probably be about a page of
simple code.  You could run it from your local directory, just like
you run a Python module.

> This is the code as it is now, it works allright but the profiler says
> we spend a lot of time here:
> for j in range(self.nh):
>     sum = 0.0
>     for i in range(
>         sum = sum +[i] * self.wi[i][j]
> the .nh and .ni values are correct

What are their relative magnitudes?

More information about the Python-list mailing list