Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static PyObject *module_score(PyObject *self, PyObject *args) {
- int i, size, value, *gene;
- PyObject *seq, *data;
- /* Parse the input tuple */
- if (!PyArg_ParseTuple(args, "O", &data))
- return NULL;
- seq = PySequence_Fast(data, "expected a sequence");
- size = PySequence_Size(seq);
- gene = (int*) PyMem_Malloc(size * sizeof(int));
- for (i = 0; i < size; i++)
- gene[i] = PyInt_AsLong(PySequence_Fast_GET_ITEM(seq, i));
- /* Call the external C function*/
- value = score(gene, size);
- PyMem_Free(gene);
- /* Build the output tuple */
- PyObject *ret = Py_BuildValue("i", value);
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement