Embedding OCaml within Python

Jakub Fast kfast at poczta.onet.pl
Wed Apr 28 05:50:45 EDT 2004


Max Powers wrote:
> The situation is this; I've got a large legacy program that is written
> in ocaml, within which there's a parser. I'd like to be able to call
> that parser from my python program 

Doesn't the O'Caml compiler translate the code into C first?

If you got it to generate C code for your your library, chances are you 
could dig into it and wrap whatever you got there with SWIG or BPL, and 
then compile both the wrapper and the lib in C.

Then,

 > Python -> C extension -> OCaml -> callback to C -> callback to Python

becomes

Python -> C extension (O'Caml translation + callback to Python)


Of course, it might be the case that the O'Caml C code is too 
complicated or too far removed from the O'Caml object interface...

hth

kuba




More information about the Python-list mailing list