Hi,
I'm doing my first project on embedding and then extending Python in
an application. The idea is to import a set of C++ plug-ins into Python
and then be able to run a script that uses these plug-ins. Please note
that what I'm importing into Python are the plug-in classes in order to
be able to instanciate as many objects as needed.
As usual, all the plug-ins derive from a base class. But two
important things differ for each plug-in, its name and a set of
parameters.
For instance, the C++ class
class SNRFilter : public BaseFilter
{
...
};
can be instanciated in a Python script as
snr = SNRFilter()
(This is a quite simplified example as there is also a quite trivial
SNRFilterClass class deriving fron BaseFilterClass. But those are
implementation details).
So, everything works OK, but there will probably be a memory issue.
Each time I add a plug-in class into Python, I malloc a PyTypeObject
and copy its contents from a template static PyTypeObject. Then I
malloc and assign its tp_name and its tp_getset (array of PyGetSetDef).
Now the question is, how can I be sure that all this memory will be
properly free'd after calling Py_Finalize()? Is it enough to add
Py_TPFLAGS_HEAPTYPE? Can I safely free tp_getset after calling
PyType_Ready()? What will the weather be for the next week-end?
Thank you for reading.
--
Gabriel de Dietrich