[Python-3000] threading, part 2 --- + a bit of ctypes FFI worry
l.oluyede at gmail.com
Sat Aug 12 13:11:47 CEST 2006
On 8/12/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Tim Peters wrote:
> > It's unclear to me how to write portable ctypes code in the presence
> > of a gazillion integer typedefs and #defines, such as for Py_ssize_t.
> A start would be to have constants in the ctypes module
> for Py_ssize_t and other such Python-defined API types.
rctypes and pypy tools are somewhat one step further than ctypes
machinery. In rctypes you can easily do something like:
size_t = ctypes_platform.SimpleType("size_t", c_ulong)
In this way you have platform safe data type to use in your code. The
second argument of SimpleType() is a hint for the tool.
You can also use ConstantInteger() and DefinedCostantInteger() to get
values of costants in headers file like this:
BUFSIZ = ctypes_platform.ConstantInteger("BUFSIZ")
Maybe one day this can be ported to CPython ctypes from the RPython one.
More information about the Python-3000