sbinet / go-python

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

Function Calls Limited to 8 Arguments? #53

Closed smiqbal closed 7 years ago

smiqbal commented 7 years ago

I run into this problem when trying to call Python functions that require more than 8 arguments:

panic: gopy: maximum number of varargs (8) exceeded (17)

Is there any particular reason for this? Would I just need to change _gopy_PyObject_CallFunction, _gopy_PyObject_CallMethod in go-python.c and L14 in go-python.h to get around this issue?

sbinet commented 7 years ago

Syed,

On Tue, Aug 1, 2017 at 5:17 AM, Syed Iqbal notifications@github.com wrote:

I run into this problem when trying to return PyObjects over Go RPC:

2017/07/31 19:50:54 rpc: gob error encoding body: gob: type python.PyObject has no exported fields

The object itself is an sklearn.tree.DecisionTreeClassifier. I know this is probably an unreasonable request (considering that the encoding for such a general object is not trivial), but is there a chance that this will be addresses in a future release? I want to avoid having to create multiple encodings for different sklearn classifiers.

this doesn't look like something easily doable: one would need to re-create the CPython value on the other end of the wire, together with all the other possible python values that the python.PyObject may have referenced, and then create a suitable go-python value that wraps the CPython value.

that said, you might be better off pickling the DecisionTreeClassifier, send that over the wire, and create a new python.PyObject out of that.

hth, -s

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sbinet/go-python/issues/53, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBXSImw3wOiI6dKS7uLr78ou3_Yb-18ks5sTpjZgaJpZM4OpLh5 .

smiqbal commented 7 years ago

Yes, I ended up just pickling the DecisionTreeClassifier instead. Thanks for the response.