Converting Python code to C/C++

Andras Pikler Andras.Pikler at
Mon Jun 22 22:49:48 EDT 2009


Short: I need to turn a Python program that I (mostly) wrote into C code, and I am at a loss.

Long: I'm doing research/programming for a professor, and we are working with MIDI files (a type of simple music file). The research deals with generating variations from a musical melody; currently, my Python code uses a Python midi package<> I found online to read the notes in question from a midi file, about 350 lines of my own code to generate a variation based on these notes and the professor's algorithms, and finally the package again to write the new melody to another midi file.

Now, my professor would like to have this exact code in C/C++, as she believes C is more compatible with MATLAB, and wants the code to be available in multiple languages in case a programmer works for her in the future who knows C but not Python. While I know a tiny bit of C (emphasis on the tiny), I would much prefer if there were some sort of automatic compiler I could use to turn my Python code into C than taking a week or two or three to learn the minimum I need about C, find a way to access MIDI files in it, and rewrite all of my code.

After some googling, I found and tried Shedskin<>, but it doesn't work, as the Python midi package I'm using uses modules which Shedskin does not support. Otherwise, I haven't found much. Is there anything out there to help me do this? If not, from anyone who has experience in this regard, how daunting should I expect this to be?

Any help is appreciated. Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list