Module Extension C/CPI Question
gnb at itga.com.au
Wed Aug 10 09:34:43 CEST 2005
Jeremy Moles wrote:
> Or, perhaps, there's even a better way? I'm getting more and more
> experienced with the Python/C API, so I don't need a walk-through or
> anything. :) Just an experienced recommendation...
Better by far to create a new python type in C that has your struct
inside it and use PyMemberDefs to make those members automagically
available to Python. This has the monster advantage that members are
only converted from C objects to Python objects if they are referenced -
which is likely to have serious performance advantages if (as seems
likely with really large data objects) most of the members of most of
the objects aren't ever referenced.
See the "Embedding & Extending" document, Chapter 2.
More information about the Python-list