Pyrex: wrapping C struct as Python class
Edward C. Jones
edcjones at erols.com
Thu Apr 10 11:43:23 EDT 2003
I have a C struct and functions that use it:
tiny.h:
typedef struct {
int ival;
} Tiny;
int square(Tiny* t);
tiny.c:
int squareit(Tiny* t)
{
return t.ival * t.ival;
}
In C code, I would use "malloc", "free" and "squareit" with Tiny. What
is the best way to wrap this in Pyrex so Python code can do
t = Tiny(77)
print t.ival
print t.squareit()
del t
More information about the Python-list
mailing list