Easier to wrap C or C++ libraries?

Hrvoje Niksic hniksic at xemacs.org
Mon Feb 16 14:48:02 EST 2009


Nick Craig-Wood <nick at craig-wood.com> writes:

> 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.

I apologize for the misinformation that ctypes doesn't work on 64-bit
systems.  The project I'm working on doesn't include ctypes, but it
could be because we don't use GCC to build, or because we also need to
support Win64.



More information about the Python-list mailing list