[PyKDE] SIP vs Boost.Python?
James Emerton
ephelon at gmail.com
Thu May 12 19:08:44 BST 2005
Here's the most maintainable way of calling Python from C++. This
method keeps your C++ out of your Python and your Python out of your
C++. As a bonus feature, if the Python implementation gets too slow,
you can rewrite in C++ without needing to touch any client code.
//
// iface.h
struct IFoo {
virtual float wonk(float, float) = 0;
};
//
// iface.sip
%Module foo
class IFoo {
%TypeHeaderCode
#include "iface.h"
%End
public:
virtual float wonk(float, float) = 0;
};
//
// impl.py
from foo import IFoo
class FooImpl( IFoo ):
def wonk( self, n1, n2 ):
return n1 * n2
The only thing left to do in instantiate FooImpl and hand it back to
some C++ function.
James
More information about the PyQt
mailing list