Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile DLL from python code

Hi does anyone know if you can compile Python code into a Windows DLL file? How would you go about doing this?

like image 718
Martin Avatar asked Mar 18 '11 12:03

Martin


People also ask

Can you compile a python script?

Python, as a dynamic language, cannot be "compiled" into machine code statically, like C or COBOL can. You'll always need an interpreter to execute the code, which, by definition in the language, is a dynamic operation.


1 Answers

One way would be to create a C or C++ library that embeds the Python interpreter and runs your Python code.

Another option would be to translate you Python code to C++ with ShedSkin and make that a DLL, although I wouldn't expect a very clean API to come out of this.

like image 178
Martin Blech Avatar answered Oct 01 '22 16:10

Martin Blech