On May 21, 2008, at 3:58 PM, Jean-Paul Calderone wrote:
Plus, even if ctypes works, the code might be incorrect, because they
had been assuming structure layouts and symbolic constants that have
just a different definition on some other platform, causing the
extension module to crash.

Writing portable ctypes modules is really hard - significantly harder
than writing portable C code (although writing non-portable ctypes
code is apparently easier than writing non-portable C code).

True.  There's some room for improvement in ctypes here, fortunately.

For example, PyPy has some tools which resolve the particular problem
you're talking about; the library is even available separately and can
(and probably should) be used by anyone writing a ctypes module.

Sample usage and installation instructions available here:

http://codespeak.net/~fijal/configure.html

The "csvn" subversion bindings use "ctypesgen" to grovel header files:
http://code.google.com/p/ctypesgen/

There's also ctypeslib, which uses gcc-xml to parse the headers instead of a pure python C parser as ctypesgen does:
http://svn.python.org/projects/ctypes/trunk/ctypeslib/

I don't really know how all these tools compare to eachother. It sure would be nice if someone could compare them, and figure out if one can be "blessed" and included with python so that doing the right thing is easy.

James
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to