#define PY_SSIZE_T_CLEAN
#include <Python.h>
static PyObject* single_arg(PyObject *args)
{
if (!PyArg_ParseTuple(args, "O", &args)) {
return NULL;
}
return args;
}
static int sequence_to_array(PyObject *seq, double *array, Py_ssize_t size)
{
if (seq == NULL || PySequence_Size(seq) != size) {
return 0;
}
while (size--) {
array[size] = PyFloat_AsDouble(PySequence_GetItem(seq, size));
}
return 1;
}
static PyObject *func(PyObject *self, PyObject *args)
{
double array[3];
if (!sequence_to_array(single_arg(args), array, 3)) {
return NULL;
}
Py_RETURN_NONE;
}
I2RlZmluZSBQWV9TU0laRV9UX0NMRUFOCiNpbmNsdWRlIDxQeXRob24uaD4KCgpzdGF0aWMgUHlPYmplY3QqIHNpbmdsZV9hcmcoUHlPYmplY3QgKmFyZ3MpCnsKCWlmICghUHlBcmdfUGFyc2VUdXBsZShhcmdzLCAiTyIsICZhcmdzKSkgewoJCXJldHVybiBOVUxMOwoJfQoKCXJldHVybiBhcmdzOwp9CgoKc3RhdGljIGludCBzZXF1ZW5jZV90b19hcnJheShQeU9iamVjdCAqc2VxLCBkb3VibGUgKmFycmF5LCBQeV9zc2l6ZV90IHNpemUpCnsKCWlmIChzZXEgPT0gTlVMTCB8fCBQeVNlcXVlbmNlX1NpemUoc2VxKSAhPSBzaXplKSB7CgkJcmV0dXJuIDA7Cgl9CgoJd2hpbGUgKHNpemUtLSkgewoJCWFycmF5W3NpemVdID0gUHlGbG9hdF9Bc0RvdWJsZShQeVNlcXVlbmNlX0dldEl0ZW0oc2VxLCBzaXplKSk7Cgl9CgoJcmV0dXJuIDE7Cn0KCnN0YXRpYyBQeU9iamVjdCAqZnVuYyhQeU9iamVjdCAqc2VsZiwgUHlPYmplY3QgKmFyZ3MpCnsKCWRvdWJsZSBhcnJheVszXTsKCglpZiAoIXNlcXVlbmNlX3RvX2FycmF5KHNpbmdsZV9hcmcoYXJncyksIGFycmF5LCAzKSkgewoJCXJldHVybiBOVUxMOwoJfQoKCVB5X1JFVFVSTl9OT05FOwp9