0

How to compile .py scripts to .obj files if it is possible ?

Can a python script and a c file be compiled and linked to an exe.

1 Answers1

0

I'm not sure what problem you're trying to solve. Your question is too broad.

Python compiles all code automatically, but it generates .pyc files with the python bytecode, then needs a VM to execute it, similar to other languages like C# and java.

To integrate with C the usual approach is to make a C extension to python, then you can call it from the python code.

If you want to generate a .exe from python code, the go-to method is to use something like pyinstaller, that bundles python, all libraries and your code in a single .exe file and unpacks it on execution.

If you really want to convert a python code to machine-readable x86 code (why) then you can use something like cython (converts python-like code to C code); The results are probably not what you expect though.

nosklo
  • 217,122
  • 57
  • 293
  • 297