You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
@elbaro, unfortunately, cgo doesn't handle C functions that are variadic (IIRC).
so, essentially, one would need to implement Py_BuildValue in terms of e.g.PyTuple_New + PyTuple_SET_ITEM.
and, for this to work, one would need to also implement a parser for the Py_BuildValue(format) string to infer the tuple size and the various types for the elements of that tuple:
What about a hacky solution where there are a bunch of C wrapping functions with a fixed number of parameters. This code is obviously wrong, but it gets the idea across:
Activity
sbinet commentedon Jan 19, 2018
@elbaro, unfortunately,
cgodoesn't handle C functions that are variadic (IIRC).so, essentially, one would need to implement
Py_BuildValuein terms of e.g.PyTuple_New+PyTuple_SET_ITEM.and, for this to work, one would need to also implement a parser for the
Py_BuildValue(format)string to infer the tuple size and the various types for the elements of that tuple:that said that could be done. PR accepted :P
sbinet commentedon Jan 19, 2018
(note that, according to Python2 C-API
Py_BuildValuedoesn't always return a slice, so this should also be taken care of...)icholy commentedon Jun 14, 2019
What about a hacky solution where there are a bunch of C wrapping functions with a fixed number of parameters. This code is obviously wrong, but it gets the idea across:
sbinet commentedon Jun 14, 2019
SGTM.
that's actually what I did there:
https://github.com/sbinet/go-python/blob/master/go-python.c#L16 for
PyObject_CallFunction