Archived

This forum has been archived. Please start a new discussion on GitHub.

Transfering classes between Python and C++

Hi!

I've got the following problem: I'm considering to port an application which doing considerable mathematical stuff over to Ice, but that would require me to use both C++ and Python interfaces. Now the problem is that we so far have written all the math classes in C++ and we would need to be able to create copies of them in Python. To this end, the class slice type would get me the class copied, but that would end up with a reimplementation of all the math code in Python, which would be serious code duplication.

Can you suggest a way in which we can use the C++ implementation of the classes in Python client processes? My current thoughts are about using the current boost::python wrapper to the C++ code and the required Python class factories to create classes which are derived from both the slice base interface and the C++ classes. Could that approach work?

Comments

  • mes
    mes California
    Yes, that sounds like a reasonable approach. I assume that you have good reasons for using Python, because it would likely be simpler to use only C++. :)

    Take care,
    - Mark
  • So far, the interfaces between Python and C++ have been pretty easy to do. And we have a pretty good reason to do that. So I hope you don't want to hint at troubles that may arise from using Ice and IcePy together... ;)
  • mes
    mes California
    No, I'm not trying to drop any hints. :)

    Good luck with your project.

    - Mark
  • Thank you for your help, Mark!