I am trying to embed a c function in my python script for a first time.
When I try to call it I get an error
SystemError: new style getargs format but argument is not a tuple
Guido said on some mailing list, that it is probably an effect of the
lack of METH_VARARGS in the functions' array, but it's ok in my source
code. Here is the full code:
#include <python2.4/Python.h>
static PyObject * mandelpixel(PyO bject *self, PyObject *args)
{
double z_real = 0, z_imag = 0, z_real2 = 0, z_imag2 = 0, c_real,
c_imag, bailoutsquare;
int iteration_numbe r;
register int i;
PyObject coord;
if (!PyArg_ParseTu ple(args, "Oid", &coord, &iteration_numb er,
&bailoutsquare) )
return NULL;
if (!PyArg_ParseTu ple(&coord, "dd", &c_real, &c_imag))
return NULL;
for(i = 1; i <= iteration_numbe r; i++)
{
z_imag = 2 * z_real * z_imag + c_imag;
z_real = z_real2 - z_imag2 + c_real;
z_real2 = z_real * z_real;
z_imag2 = z_imag * z_imag;
if (z_real2 + z_imag2 bailoutsquare)
return Py_BuildValue(" i", i);
}
return Py_BuildValue(" i", 0);
}
static PyMethodDef MandelcMethods[] =
{
{
"mandelpixe l", mandelpixel, METH_VARARGS, "check the pixel for
Mandelbrot set"
},
{
NULL, NULL, 0, NULL
}
};
PyMODINIT_FUNC initmandelc(voi d)
{
(void) Py_InitModule ("mandelc", MandelcMethods) ;
}
int main(int argc, char **argv)
{
Py_SetProgramNa me(argv[0]);
Py_Initialize() ;
initmandelc();
return 0;
}
Greets
zefciu