473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

create a c++ wrapper for python class?

Right now I'm using Boost Python to wrap some C++ code so
that applications from both languages can use it.

This is great, but I'm rapidly coming to the conclusion that
a lot of this work is better coded in Python. There's nothing
particularly CPU-bound, and the comprehensive Python library is a
big help.

So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.

Of course, the usual restrictions apply: no dynamically
added methods, accessing all instance data via getters
and setters, etc.

It seems a first cut of this is pretty straightforward,
using introspection to get the required methods. Something
needs to be done to specify the C++ types of the parameters.

Is there any work being done in this area?

Many TIA,
Mark

--
Mark Harrison
Pixar Animation Studios
May 10 '06 #1
1 1842
Mark Harrison schrieb:
Right now I'm using Boost Python to wrap some C++ code so
that applications from both languages can use it.

This is great, but I'm rapidly coming to the conclusion that
a lot of this work is better coded in Python. There's nothing
particularly CPU-bound, and the comprehensive Python library is a
big help.

So, I'm looking for a C++ wrapper generator, so that I can
write a class in Python, and then have a .h and .cpp generated
that will give me a corresponding C++ class.

Of course, the usual restrictions apply: no dynamically
added methods, accessing all instance data via getters
and setters, etc.

It seems a first cut of this is pretty straightforward,
using introspection to get the required methods. Something
needs to be done to specify the C++ types of the parameters.

Is there any work being done in this area?


No - and I doubt there is much to do about that. C++ needs so many
static information to form a proper class, you'd end up duplicating the
whole declarational efforts in some awkward addition or complementary
annotation to python's syntax that it just isn't feasible. There is
shedskin, avery interesting project, but then this sufers from being a
subset of python and AFAIK no seamless interoperability between python
and C++.

I don't know about boost - but I know my way around SIP a little bit.
So what I would do is to declare whatever you need in C++ in a class
with all virtual methods. SIP then should be able to let you subclass
that class in python, and pass back instances of your python classes to
your C++-core/library/whatever.

Diez
May 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roy Smith | last post by:
I had a class called rule and a subclass of rule, called bgpRule, in a file called bgp.py. I decided to move the rule class to its own file, called rule.py. The original file did "import rule"....
3
by: Whitney Battestilli | last post by:
I'm trying to embed python into an application that already contains a scripting language. This scripting language contains thousands of commands and I have the ability to query the script engine...
4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
12
by: Egil M?ller | last post by:
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for...
14
by: Java and Swing | last post by:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) { // this will store the result in a Python object PyObject *finalResult; // get arguments from Python char *result = 0; char *in=...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
2
by: GinTon | last post by:
EyeDB is a free ODBMS based on the ODMG 3 specification with programming interfaces for C++ and Java. It is very powerfull, mature, safe and stable. In fact, it was developed in 1992 for the Genome...
0
by: Stou Sandalski | last post by:
Hi, I have a python library created by wrapping the C++ library using Boost.Python, the problem is that the wrappers are not very pythonic.... so I want to add some methods that do not exist in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.