setup() and C extensions

7stud bbxx789_05ss at yahoo.com
Tue Apr 10 02:35:35 EDT 2007


Also:

1) When you create a C array to map python names to the C functions
that you defined:

static PyMethodDef MyFunctions[] =
{
    {"my_calc", (PyCFunction)my_func, METH_VARARGS, "my very speedy c
function"},
    {NULL, NULL, 0, NULL}
};

Why do you need to cast my_func to PyCFunction?


2) When returning None, why use the idiom:

Py_INCREF(Py_None);
return Py_None;

instead of:

return Py_BuildValue("");




More information about the Python-list mailing list