list math for version 1.5.2 without Numeric

J.Jacob joost_jacob at hotmail.com
Wed Nov 28 09:21:52 EST 2001


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).

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(self.ni):
        sum = sum + self.ai[i] * self.wi[i][j]

the .nh and .ni values are correct
I have been trying things like 

import operator
reduce(operator.add, map( operator.mul, ... ))

but i am not at all used to optimization wizardry so i have no idea if
i can find a good solution.
Any expert wants to help ?



More information about the Python-list mailing list