C++ - Python API

Thomas Jollans thomas at jollybox.de
Wed Sep 1 16:29:42 EDT 2010


On Wednesday 01 September 2010, it occurred to Markus Kraus to exclaim:
> So the feature overview:

First, the obligatory things you don't want to hear: Have you had a look at 
similar efforts? A while ago, Aahz posted something very similar on this very 
list. You should be able to find it in any of the archives without too much 
trouble.
The most prominent example of this is obviously Boost.Python.

> For C++ classes:
> - "translating" it into a python object

How do you handle memory management ?

> - complete reflexion (attributes and methods) of the c++ instance
> - call c++ methods nearly directly from python
> - method-overloading (native python doesnt support it (!))
> 
> Modules:
> - the API allowes to create hardcoded python modules without having
> any knowledge about the python C-API
> - Adding attributes to the module (long/char*/PyObject*)

char*...
Unicode? Somewhere? wchar_t* maybe, or std::wstring? No? Also -- double? (I'm 
just being pedantic now, at least double should be trivial to add)

> 
> General:
> -runs on any platform and doenst need an installed python

Which platforms did you test it on? Which compilers did you test? Are you sure 
your C++ is portable?

> -runs in multithreaded environments (requires python > 2.3)

How do you deal with the GIL?
How do you handle calling to Python from multiple C++ threads? 

> -support for python 3.x
> -no need of any python C-API knowledge (maybe for coding modules but
> then only 2 or 3 functions)
> -the project is a VC2010 one and there is also an example module +
> class

Again, have you tested other compilers?

> If there is any interest in testing this or using this for your own
> project, please post; in that case i'll release it now instead of
> finishing the inheritance support before releasing it (this may take a
> few days though).

Just publish a bitbucket or github repository ;-)



More information about the Python-list mailing list