[Numpy-discussion] Record Arrays and ctypes Interfacing
Tue Mar 18 13:18:27 CDT 2008
On Tue, Mar 18, 2008 at 9:48 AM, <firstname.lastname@example.org> wrote:
> Hi all,
> How do I handle numpy record arrays (heterogenous dtype) with ctypes?
> The python side is reasonably obvious to me, but I'm confused about
> how to declare my C function's signature; whether I need to include
> the numpy array interface header file or not... etc...
> It's not obvious to me how a heterogeneous dtype is handled on the C
> side. Could someone give me a quick and dirty example.
Record arrays (loosely) correspond to arrays of C structs. The
correspondence is only loose because the C standard does not specify
how the struct members should be aligned. Different systems may place
padding in places where numpy didn't. There are often #pragmas one can
use to force a particular kind of padding. Here is a reasonably good
article on the subject:
You shouldn't need any numpy headers.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion