Code Monkey home page Code Monkey logo

Comments (5)

sbinet avatar sbinet commented on June 11, 2024

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!)

from go-python.

tfogal avatar tfogal commented on June 11, 2024

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:

http://blog.enthought.com/python/numpy/simplified-creation-of-numpy-arrays-from-pre-allocated-memory/

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.

from go-python.

sbinet avatar sbinet commented on June 11, 2024

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.

from go-python.

tfogal avatar tfogal commented on June 11, 2024

Sounds great, thanks!

from go-python.

sbinet avatar sbinet commented on June 11, 2024

fixed with 06cbd38

from go-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.