9

Possible Duplicate:
How can I use C++ class in Python?

I am designing a software in python but I am experiencing some memory problems while implementing it with python so I am planning to extend my software with C++. So I was thinking can I use C++ defined class and use it in python as Superclass and override some of its methods?

Community
  • 1
  • 1
Robins Gupta
  • 3,143
  • 3
  • 34
  • 57
  • What are you looking at? Boost Python? Swig++? – sehe Sep 28 '12 at 10:23
  • 4
    The question is very interesting, but a bit vague. You can write a C Python extension that implements a Python class, and once it's accessible from Python you can override whatever pleases you. Perhaps you should go ahead do it and come back with any specific problems you encounter. – deStrangis Sep 28 '12 at 10:32
  • 1
    http://efesx.com/2012/09/30/python-directing-cpp/ – sehe Oct 02 '12 at 12:18

1 Answers1

6

The answer is yes.

You can inherit and extend the class using boost.python. Please take a look how to do that.

However, to override the methods of base C++ class the way is bit more complex, please take a look at this article on the subject.

Also, I would have considered to think how to avoid using inheritance and use wrappers instead for your C++ class, if that is possible.

pershyn
  • 134
  • 6