Python Forum

Full Version: Python to DLL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, Python Forum Smile

I'm a new member here. And also new in Python.
My name is Stephanus, you can call me Steven, from Indonesia.

I would like to know if we can compile Python to DLL file.

def my_function(x):
return(x * 2)



Suppose I have a very simple function like that one above.
How can I compile it to .DLL so that I can call it in Delphi or C.

Thank you very much.
I'd really appreciate your help.
It does not work exactly this way. C programs that execute Python code load the Python library which contains a whole set of C functions to communicate with the Python interpreter.

Start by reading Extending and Embedding the Python Interpreter (obviously the «embedding» part is what you are looking for), then have a look at the Python C Api reference manual.
(May-25-2022, 07:08 PM)Gribouillis Wrote: [ -> ]It does not work exactly this way. C programs that execute Python code load the Python library which contains a whole set of C functions to communicate with the Python interpreter.

Start by reading Extending and Embedding the Python Interpreter (obviously the «embedding» part is what you are looking for), then have a look at the Python C Api reference manual.

Thank you very much Gribouillis