Embedding Python in C
Jesse Ibarra schrieb am 20.07.19 um 04:12:
> Sorry, I am not understanding. Smalltlak VW 8.3 does not support Python.
> I can only call Pyhton code through C/Python API.
Ok, but that doesn't mean you need to write code that uses the C-API of
Python. All you need to do is:
1) Start up a CPython runtime from Smalltalk (see the embedding example I
posted) and make it import an extension module that you write (e.g. using
the "inittab" mechanism ).
2) Use Cython to implement this extension module to provide an interface
between your Smalltalk code and your Python code. Use the Smalltalk C-API
from your Cython code to call into Smalltalk and exchange data with it.
Now you can execute Python code inside of Python and make it call back and
forth into your Smalltalk code, through the interface module. And there is
no need to use the Python C-API for anything beyond step 1), which is about
5 lines of Python C-API code if you write it yourself. Everything else can
be implemented in Cython and Python.