Confused about extending.

Chris Gonnerman chris.gonnerman at usa.net
Thu Feb 22 00:02:45 EST 2001


----- Original Message -----
From: "Joonas Paalasmaa" <joonas at olen.to>
Subject: Confused about extending.


> I have made the following C-function and now I would like to
> use it via Python in that way, that it would
> manipulate Python lists smoothedValues and originalValues.
> But I am just a beginner with C and I got confused with extending HowTo.
> I would be glad if someone would explain how to manipulate the code to
> make it extendingable.
>
> Joonas.

I'm puzzled as to why you have implemented this function in C instead of
Python.  Is it for
speed?  Just how big ARE your lists?

> void SmoothedList(double *originalValues, double *smoothedValues,
>         int listSize, int filterSize)
> {
>         double tmpResult;
>         int i, j;
>         int iterations = listSize - filterSize + 1;
>
>         for(i = 0; i < iterations; i++)
>         {
>                 for(j = 0, tmpResult = 0.0; j < filterSize; j++)
>                         tmpResult += originalValues[i + j];
>                 smoothedValues[i] = tmpResult / (double)filterSize;
>         }
> }

def SmoothedList(originalValues, smoothedValues, listSize, filterSize)
    iterations  =  listSize - filterSize + 1;
    for i in range(0,iterations):
        tmpResult = 0.0
        for j in range(0, filterSize):
            tmpResult  =  tmpResult + originalValues[i + j]
            smoothedValues[i] = tmpResult / filterSize

------------------------------------
Have I missed something here?








More information about the Python-list mailing list