Python as scripting plug-in for large C++ project
Daniel Dittmar
daniel at dittmar.net
Sat Apr 27 15:01:10 EDT 2002
Bjorn Pettersen wrote:
> - We extensively (exclusively) use our own basic datatypes,
> e.g. NInteger which in addition to keeping a value also
> stores whether it is NULL (think databases). How much work
> is it going to be to expose these to embedded Python?
When mapping from/to Python, translate NULL values to Py_None. Creating
multiple full fledged numeric types is probably more trouble than it is
worth.
> - Our object/relational mapping tool (written in Python :-)
> outputs ~100KLocs of C++ that defines an object tree that
> ends in timeseries data ("vectors") or records. The code
> is highly optimized and makes sure we keep data integrity.
> Would it be simpler to use SWIG/SIP/boost to expose this,
> or would it be just as easy to have the mapping tool
> generate the Python glue directly.
Just a shot in the dark: having both C++ and Python representation of
the same data in memory will probably make data integrity quite
difficult, so expose your current data structures via SWIG etc. for
production use. You might also think about generating the Python glue
directly. This isn't really that difficult. It might actually be easier
to generate this with your knowledge of the data structures rather than
trying to sqeeze it into the SWIG etc. input.
Generating Python bindings directly will give you a great tool to play
with new ideas, so I would probably (time permitting) add this one as well.
Daniel
More information about the Python-list
mailing list