GithubHelp home page GithubHelp logo

Comments (9)

UnixJunkie avatar UnixJunkie commented on July 21, 2024 1

Supporting all the ocaml types (and their python equivalent) would be nice: int, char, float, bool, string.

from ocaml_python_bindgen.

UnixJunkie avatar UnixJunkie commented on July 21, 2024 1

I hereby confirm that a hacker (@mooreryan) killed this feature request.

from ocaml_python_bindgen.

mooreryan avatar mooreryan commented on July 21, 2024

Hey so what kind of function are you wrapping...could you put a little example?

And assuming that the python function returns an actual python tuple...how you would like to use it from the OCaml side? Converting tuples into something usable from the OCaml side is flexible in pyml...you can treat them as OCaml tuples, or lists, or arrays, or even as an abstract type, so I'm curious how you would like to use it.

Also, would it be mainly returning tuples, or letting tuples be parameters for functions as well?

Currently I deal with tuples like this or sometimes like this if you need functors. But I could see how a more "natural" support for tuples would be helpful...it's just a matter of finding a pleasant way to deal with them.

from ocaml_python_bindgen.

UnixJunkie avatar UnixJunkie commented on July 21, 2024

The functions were like these:

# assert(get_distances(m) == [(0, 1, 1),
#                             (0, 2, 2),
#                             (0, 3, 3),
#                             (0, 4, 2),
#                             (0, 5, 1),
#                             (1, 2, 1),
#                             (1, 3, 2),
#                             (1, 4, 3),
#                             (1, 5, 2),
#                             (2, 3, 1),
#                             (2, 4, 2),
#                             (2, 5, 3),
#                             (3, 4, 1),
#                             (3, 5, 2),
#                             (4, 5, 1)])
# assert(type_atoms(m) == [(6, 2, 1, 3, 0),
#                          (6, 2, 1, 3, 0),
#                          (6, 2, 1, 3, 0),
#                          (6, 2, 1, 3, 0),
#                          (6, 2, 1, 3, 0),
#                          (6, 2, 1, 3, 0)])

I was just looking for returning tuples, and the tuple values were all of the same type (int, in this example).
I think python tuples should be mapped to ocaml tuples by default (maybe some users will want
to translate them to list/array, but I feel this should not be the default).

from ocaml_python_bindgen.

mooreryan avatar mooreryan commented on July 21, 2024

Okay, I see now...yeah I've hacked together some basic tuple support, but not yet tuples within lists/arrays/seqs. I will play around with it some more and see if there is any weirdness when dealing with them in general.

from ocaml_python_bindgen.

UnixJunkie avatar UnixJunkie commented on July 21, 2024

I would really love to have tuples being supported, at least as return type of python functions.
They should be mapped to an ocaml tuple (type: 'a * 'b * 'c).
Of course, in the interface, we would fix those type variables to some concrete type (possibly any basic OCaml type: int, float, char, string, whatever).

from ocaml_python_bindgen.

UnixJunkie avatar UnixJunkie commented on July 21, 2024

As a kind of sponsorship, I can send you my copy of the book moneyball, if that interests you. :)

from ocaml_python_bindgen.

mooreryan avatar mooreryan commented on July 21, 2024

Haha, I do love moneyball. Anyway, tuple support is finally here, and in version 0.3.0! You can see some examples of usage here.

(Currently not on opam yet, but you could pin it.)

Let me know if this works for you!

from ocaml_python_bindgen.

UnixJunkie avatar UnixJunkie commented on July 21, 2024

Ok, I will test and let you know.

from ocaml_python_bindgen.

Related Issues (10)

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.