[Tutor] improving speed using and recalling C functions
Steven D'Aprano
steve at pearwood.info
Fri Apr 11 02:59:05 CEST 2014
On Thu, Apr 10, 2014 at 11:58:30AM -0400, Gabriele Brambilla wrote:
> Hi,
>
> I have a program that is reading near 600000 elements from a file.
> For each element it performs 200 times a particular mathematical operation
> (a numerical interpolation of a function).
> Now these process takes near 8 hours.
Why are you repeating each operation 200 times? Surely you don't mean
something like this?
for element in elements_from_file():
for i in range(200):
result = function(element)
Before spending your time re-writing the function in C, it may help
checking that there are no inefficencies in the code. Calculating the
function may not be what is slowing your code down.
It might help if you show us your code.
--
Steven
More information about the Tutor
mailing list