Comments (9)
Supporting all the ocaml types (and their python equivalent) would be nice: int, char, float, bool, string.
from ocaml_python_bindgen.
I hereby confirm that a hacker (@mooreryan) killed this feature request.
from ocaml_python_bindgen.
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.
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.
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.
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.
As a kind of sponsorship, I can send you my copy of the book moneyball, if that interests you. :)
from ocaml_python_bindgen.
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.
Ok, I will test and let you know.
from ocaml_python_bindgen.
Related Issues (10)
- embedding more than one python file HOT 5
- adder.py needs to be in the current working directory HOT 8
- Generated OCaml interface's style HOT 6
- You don't always need to generate the pyobject conversions functions
- --embed-python-source HOT 29
- "could not create val_spec" is not very helpful HOT 3
- t option and custom option arguments are tricky to handle correctly HOT 1
- pyml_bindgen invocation example in case there is no class [question] HOT 4
- there are many depends in the opam file HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml_python_bindgen.