Closed tfogal closed 9 years ago
I can of course expose togo
- which I would probably expose as:
func PyObject_FromVoidPtr(ptr unsafe.Pointer) *PyObject { ... }
but, as you mentionned numpy
, perhaps a more useful API to expose would be capsules ?
https://docs.python.org/2/c-api/capsule.html#capsules
(BTW: any pointer to your numpy-based+go project? color me interested!)
I am/was not familiar with capsules. AFAICT, however, this is an orthogonal concept, no? I still need SimpleNewFromData
from NumPy---my use case is the same as Travis', here:
but he's unfortunately using the CObject way there. Charles Harris explicitly notes that NumPy uses the CObject method internally:
https://bugzilla.redhat.com/show_bug.cgi?id=623857#c3
So perhaps that forces our hand to use the old way? It is (very) possible that I'm misunderstanding how this would work with capsules, though. Would welcome some education on that.
Re: the project, the code is here:
https://github.com/tfogal/visdebug
but there's far too much to grok. We're preparing a manuscript to submit academically, but I'm too embarrassed about its current state to post it publicly. Happy to send it to you via email, though.
I proposed PyCapsules
because PyCObject
are deprecated in 2.7, but I can as easily wrap PyCObject
. would that work for you ?
but, ok. if somebody were to wrap, say, numpy
with cgo
, she would still need a way to convert an unsafe.Pointer
into a python.PyObject
.
so... I'll start with exposing togo
via PyObject_FromVoidPtr
.
Sounds great, thanks!
fixed with 06cbd3801e
Just getting started with this wrapper. Great so far, thank you!
I have a need to create NumPy arrays from some Go code. I started this externally to the project, but I quickly ran up against the issue that NumPy creates PyObject* that should be treated in the go-python way, but I can't get these into go-python.
The 'togo' function is not public. However, even making it public does not help much, due to Go typing issues: _Ctype_PyObject != python._Ctype_PyObject (in English, C.PyObject in another package is a distinct type from C.PyObject from within the package).
To workaround this, I've been using the following patch that simple exports a modified 'togo'.
Any chance we could get something like this in the shipped version?