Vijay
Vijay

Reputation: 944

Need help converting python code to c code

Is there any compiler which will help me convert my python code to proper C code? In my python code I am using the xml.dom.minidom module to parse an xml and process the results obtained by ElementsByTagName. I don't know of any such compiler which will help me convert this kind of python code to C code.

My intention is to convert python code to a readable C code which may later be compile to an .exe file. Cython will not be of much use to me as it is in the end writing c extensions which will later be used in python. However, I wish to use this as a proper standalone readable C code which can later be shared with users - the c source code along with its corresponding .py file.

My main impediment here is writing out the C code manually myself, my C skills are quite poor and it would require a more effort to sharpen my C skills before writing the code myself, I can not afford that luxury of time.

I was surfing and came across shedskin, but that might not just support the xml.dom.minidom module for my purposes

The only similar question to mine on stackoverflow: Is there any free Python to C translator? does not help me out much as Cython will not help me and shedskin does not seem to support xml.dom.minidom module.

Any pointers?

Upvotes: 1

Views: 409

Answers (2)

Michael Dillon
Michael Dillon

Reputation: 32392

You are looking in the wrong direction. Instead of looking for a generic Python to C compiler to make xml.dom.minidom more efficient, replace the library with lxml which is already compiled C code. The lxml module uses libxml2 and libxslt.

In general, you get more optomization in Python, with less work, by choosing modules that more efficient.

Upvotes: 2

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83666

There are no Python to C translators which would produce human-readable, editable, C source code.

Upvotes: 4

Related Questions