La storia: sto provando ad interfacciare da C a Python per usare la più veloce velocità di calcolo di C per un codice Python esistente. Ho già avuto un certo successo, anche con il passaggio degli array NumPy - ma ora sembra che ci sia un problema e non riesco a risolverlo. Questo è il codice:Python - SystemError: risultato NULL senza errore nella chiamata PyObject
#define FORMAT_VALUE_T "d"
char format_buffer[32];
typedef struct
{
PyObject_HEAD
PyArrayObject *invmat;
unsigned order;
value_t weight, *buffer;
} Det;
typedef double value_t;
typedef struct
{
PyObject_HEAD
Det *det;
value_t *row, *covs, ratio, star;
} DetAppendMove;
static int append_init(DetAppendMove *self, PyObject *args, PyObject *kwds)
{
value_t star, *temp;
PyArrayObject *row, *col;
PyObject *result = Py_BuildValue("(i)",1);
Det *dete;
snprintf(format_buffer, sizeof(format_buffer), "%s%s", "O!O!O!", FORMAT_VALUE_T);
if (PyArg_ParseTuple(args, format_buffer, &DetType, &dete, &PyArray_Type, &row, &PyArray_Type, &col, &star))
{
self->det = dete;
temp = (value_t*)self->det->buffer;
}
else
{
result = Py_BuildValue("(i)",-1);
}
return result;
}
Non è realmente facendo nulla, ormai, volevo solo per verificare se sono in grado di superare quelle arrays.As dice il titolo, sto ottenendo il seguente messaggio di errore:
SystemError: NULL result without error in PyObject call
Questo è interessante, dal momento che ho già passato alcuni array una volta (fatto allo stesso modo ..) e di solito questi array sono forse 100x100 se pari. Di solito le persone si sono lamentati per le matrici molto grandi ..
sto usando Ubuntu 14.04 su una macchina a 64 bit, Python V2.7.6 e Numpy 1.8.2
Sarebbe fantastico se uno di voi mi potrebbe aiutare - I non ho idea di cosa sia andato storto qui ..
EDIT: Non ho ancora capito il problema, ma a volte funziona, a volte si blocca con l'errore dall'alto .. Non ho assolutamente idea di cosa potrebbe essere - qualcuno?
Dove viene definito 'risultato'? – alk
Anche 'format_buffer' non è definito. Anche sapere come è definito "FORMAT_VALUE_T" sarebbe bello. – alk
scusa, deve aver cancellato per errore alcune cose. Dovrebbe essere ok ora. – rammelmueller