How to access C structures
Stefan Behnel
stefan_ml at behnel.de
Fri Apr 17 03:18:36 EDT 2009
Chris Helck wrote:
> I have a couple dozen C structures that define binary file records. I
> need to read the file and access the records. I need to do this very
> efficiantly.
>
> I am aware of the Python struct class, but the C structures contain
> arrays of nested structures and I'm not sure if Python struct can handle
> it. I am willing to give up portability for speed.
No need to trade, you can have both. You can implement it in Cython, a
Python-like language that supports direct interaction with C code and C
data types. It will compile to a fast C extension that you can import and
use from Python.
http://cython.org
Stefan
More information about the Python-list
mailing list