C++ and Python
aleax at mac.com
Sat Mar 10 16:50:25 CET 2007
hg <hg at nospam.org> wrote:
> target but rather C: I need to integrate a printer driver and and would
> like if possible to avoid all of the .h stuff involved with SWIG (I am not
> being sarcastic): if I can setup my prototypes directly in python, why go
> through an extra layer ?
> Aren't ctypes better suited to such an application ?
One advantage of solutions generating C code that gets compiled (SWIG,
Pyrex, writing C-API code directly, etc) is that the C compiler can warn
you, or produce compile-time mistakes, for many kinds of programming
errors; with ctypes, you will instead be finding every such error at
runtime, each time by noticing that Python crashed and facing a
substantial amount of debugging and code inspection to find out why.
More information about the Python-list