Easier to wrap C or C++ libraries?

Nick Craig-Wood nick at craig-wood.com
Sun Feb 15 11:31:55 EST 2009


Christian Heimes <lists at cheimes.de> wrote:
>  Hrvoje Niksic schrieb:
> > "Diez B. Roggisch" <deets at nospam.web.de> writes:
> > 
> >> The answer is easy: if you use C, you can use ctypes to create a
> >> wrapper - with pure python, no compilation, no platform issues.
> > 
> > The last part is not true.  ctypes doesn't work on 64-bit
> > architectures, nor does it work when Python is built with non-gcc Unix
> > compilers
> 
>  ctypes works on 64bit systems, too. However it's a pain in the ... back
>  to write code with ctypes that works across all platforms. I used to use
>  ctypes for wrapper but eventually I switched to Cython.

What sort of problems have you had?

I find as long as I use the same types as the C code actually uses it
all works fine.  If on a 64 bit platform long is 64 bits then it will
be under ctypes too.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list