[ANN] Opine 0.1.0 - Python source code transformations in OCaml

pyre-ast is an OCaml library that provides python AST representation in OCaml.

I had a need to do python source code transformations in OCaml. I made Opine to do transformations on the AST and convert it back to python. So, in OCaml, you can write python code now, if you ever need to.

P.S. It still doesn’t support the entire python syntax 100%. I haven’t added support for things like for-comprehension but it should be fairly easy to add it. I plan to add support for the missing ones as I need it for my projects.


Out of curiosity I looked at the code randomly and I see

It looks like you are building a large string by concatenating many small strings using the ( ^ ) operator, which has quadratic complexity. Unless I am missing something, this is wrong and you should be using buffers instead.


Looks like it’s not on opam?

You are right. I didn’t have a performance requirement when I was putting this together as proof of concept for people at work. But now, I think it’s better to change the implementation to use buffers

1 Like

I have a PR request to opam-repository. It’s been failing tests. I’m working my way through issues there. But I hope to have it on opam soon!

1 Like

Thanks for the feedback! I modified the logic to use buffers as opposed to using string concatenation. I will run some tests and cut a new version

1 Like