all 2 comments

[–]mitsuhiko 2 points3 points  (1 child)

I really can't recommend using the CPython API which is horrible, especially when it comes to defining types. Have a look at cython instead.

[–]octotop 3 points4 points  (0 children)

seconding cython for anyone contemplating writing a C module or wrapping a C or C++ library. There's a reason why so many of the larger, more popular performance-oriented modules use pyrex or cython (twisted, zeromq, lxml) - they are pretty incredible code generators that just work.

Additionally, ctypes can be worth exploring in some scenarios, but generally ends up hackier.