Easier to wrap C or C++ libraries?
Diez B. Roggisch
deets at nospam.web.de
Sat Feb 14 18:14:11 CET 2009
argo785 at gmail.com schrieb:
> When creating a Python binding to a C or C++ library, which is easier
> to wrap, the C lib or the C++ one? Given a choice, if you had to
> choose between using one of two libs, one written in C, the other in C+
> + -- both having approximately the same functionality -- which would
> you rather deal with from your Python code?
> It would seem to me that there's fewer design considerations when
> wrapping a library written in C; you just wrap the functions. However,
> since Python supports OOP nicely, it might also be that wrapping C++
> code *could* also be staightforward... Are there many pitfalls when
> having to map C++'s notion of OO to Python?
The answer is easy: if you use C, you can use ctypes to create a wrapper
- with pure python, no compilation, no platform issues.
Which IMHO makes a strong point for C - if you need OO, it's bolted on
easily using Python itself, by creating some nice wrapper classes.
More information about the Python-list