LWN.net Logo

C extensions

C extensions

Posted May 16, 2011 18:33 UTC (Mon) by foom (subscriber, #14868)
In reply to: C extensions by njs
Parent article: A brief experiment with PyPy

ctypes is not a great way of wrapping a C library either, since it doesn't give you access to the header files, which you need to use if you want portability.

Redefining all the structs/#defines/etc manually in ctypes is a great way to make a completely unportable library wrapper.


(Log in to post comments)

C extensions

Posted May 16, 2011 18:54 UTC (Mon) by njs (guest, #40338) [Link]

Yeah, it works well for some simpler cases, but that's why I use cython :-).

(Actually, I think most of the times I've used ctypes were to commit horrors by poking at the innards of the interpreter -- casting id(myobj) to a pointer and then screwing with C-level fields. It's not easy to guarantee portability between different implementations of a language!)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds