More details on the method table
From DANSE
The method table is like a table of contents into the dynamically loaded library that Python imports. By fixing the structure in advance, PYthon knows just how to interpret the table. The name of the method table must match the second argument to the Py_InitModule call in the init_library module. Here's what the method table would look like for the Numbers example:
static PyMethodDef numbersMethods[] =
{
{ "PyNumbers", wrap_new_Numbers, METH_VARARGS,
"PyNumbers(int, float)->new Numbers object"},
{ "Numbers_MembMult", wrap_Numbers_MemberMult,
METH_VARARGS,
"Numbers_MembMult( numbers) -> float"},
{NULL,NULL}
};
The table is an array of PyMethodDef structures. Each structure has four components: the name by which the function will be called in Python, the corresponding C function, METH_VARARGS (this never changes), and a documentation string for the function.
The {NULL,NULL} sentinel marks the end of the table for the interpretter.
