-
Notifications
You must be signed in to change notification settings - Fork 32
Embedded
Laeeth Isharc edited this page Mar 19, 2015
·
1 revision
A minimal D program with embedded python might look like this:
Of interest in pyd.pyd are PydObject, py, and d_type, which are documented elsewhere, and py_init, which calls Py_Initialize and handles details relating to extending embedded python.
This example introduces us to three new functions: on_py_init, add_module, and py_def.
add_module is used to create a new python module in the embedded interpreter. Since the underlying mechanics vary sufficiently between python 2 and python 3, add_module must only be called from within on_py_init
py_def can be used to define a python function and then call it in D as if it were a D function