sbinet / go-python

naive go bindings to the CPython2 C-API
Other
1.53k stars 138 forks source link

use ffi to handle C-varargs #22

Open sbinet opened 9 years ago

sbinet commented 9 years ago

The CPython API is using varargs a lot.

e.g.: https://docs.python.org/2/c-api/arg.html

int PyArg_ParseTuple(PyObject *args, const char *format, ...);
int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...);

consider using FFI (or github.com/gonuts/ffi) to marshal back and forth between C-varargs and Go-varargs-interface{} like is done in gopy: https://github.com/qur/gopy/blob/master/lib/utils.c#L25 https://github.com/qur/gopy/blob/master/lib/arg.go#L89