[PyKDE] SIP vs Boost.Python?

James Emerton ephelon at gmail.com
Thu May 12 17:37:41 BST 2005


There is no need for SIP to be enhanced to handle this.  (I don't
think boost::python has anything special here either.)  The Python API
can be made available by linking your application to the correct
library and calling Py_Initialize().

What you are describing is exactly what I am doing with Python and SIP.

I have a base set of accounting classes, implemented as abstract
interfaces.  I also define abstract interfaces that allow extensions
to be created and "inserted" into the basic object.  All such
interfaces have been wrapped with SIP, which gives the option of
implementing the extensions in Python.

I can also embed Python directly into C++ with PyRun_* or other, more
low level portions  the API.  In practice, there is a minimal need for
this sort of embedding.  I do some extra Python initialiazation with
PyRun_SimpleString(), just to set up an exception hook and manipulate
sys.path.

To register Python extensions, I import all the scripts in a special
directory, and they are responsible for notifying a registry object.

I hope this is of some help to you.

James



On 5/12/05, Niac Neb <niacneb at yahoo.com> wrote:
> 
> Here's my 2 cents ...
> 
> Embedding Python - C++ code that calls "embedded"
> Python code.  Embedding is inserting calls into your
> C/C++ application after it has started up in order to
> initialize the Python interpreter and call back to
> Python code at specific times. In order for Python to
> do useful things in your application, you will
> probably also need to create a Python Module object
> and somehow insert it into the Python run-time.
> 
> Extending Python - Python code that calls "extending"
> C++ code.  Extending is writing a shared library that
> the Python interpreter can load as part of an import
> statement. A strictly extended application means that
> you no longer has a C++ main() function, but rather a
> set of library functions that Python code can call.
> 
> I have a need for both.  I have an existing C++
> application (that will control the main loop).  But, I
> want to integrate Python plotting utilities.  These
> plotting utilites will retreive the plot data through
> a C++ library interface.  But, the C++ application
> will spawn these Python plotting utilities as needed.
> 
> Attached is a picture showing the complete loop ...
> Python to C++ ... C++ to Python.
> 
> Phil Thompson wrote:
> > >
> > > Will SIP be enhanced to support embedded Python?
> >
> > What do you mean by this?
> >
> > Phil
> 
> Yahoo! Mail
> Stay connected, organized, and protected. Take the tour:
> http://tour.mail.yahoo.com/mailtour.html
> 
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
> 
> 
> 
>




More information about the PyQt mailing list