[Pyrex] Python object in a struct field
Tom Locke
tom at livelogix.com
Tue Feb 8 08:21:43 CET 2005
Hi,
I'm having a go at using Pyrex to port the Logix parser
(logix.livelogix.com) to C for the speedup. The parser is very heavy on
function calls so I'm trying to migrate my Python functions to 'cdef'
functions. Where those functions are methods, I thought I would replace
the class with a C struct, and use regular C functions as 'methods'
I've immediately hit a problem in that 'object' is not allowed as the
type of a struct field.
Should I declare the field using the raw PyObject pointer type? Which
means I'll have to handle reference counting right? (how?)
Or am I making life difficult for myself? Is there a better way to go
about this? I know I could keep the Python class and just use cdef
functions, but I'd like to do away with Python's expensive attribute
access too.
Thanks!
Tom.
p.s. apologies if this is covered in some docs somewhere. I haven't been
able to track down much in the way of docs. e.g. from googling around I
notice there is a 'cdef class', but I can't see it documented anywhere.
Did I miss something, or is it just a case of keep-up-with-the-mailing-list?
More information about the Pyrex
mailing list