Python C Compatibility

I want to wrap an existing C library (pure C, namely. C ++) in Python so that I can call it from Python scripts. Which approach among the various available (C Api, SWIG, etc.) would be the most suitable?

+3
source share
3 answers

go with Ctypes, it is part of the standard distribution and works very well. basically you can wrap C structures and types in python classes as well as functions. Some types and functionality are already provided by the library.

ctypes

: C ( ), Linux, DLL .

+7

Since your code is clean, you can use Pyrex / Cython. This is not a vote issue, and Keaton has already been mentioned. I am just asking why this is the best choice for pure C.

0
source

Source: https://habr.com/ru/post/1730144/


All Articles