You should use the enumerate function for the first two for loops, this will make things easier to read. The function can probably be optimized but I will have to look at that later
Personally I haven't played around with the CPython API but you can read more on this in the Python docs.
You may also be interested in the cTypes library, which allows you to call C functions from Python.
There are so many solutions for this kind of thing including Psyco, SWIG, Boost Python, Pyrex etc. I would suggest looking at some of these and seeing which will work best for your situation.
Hope this helps,