generic way to access C++ libs?

Thomas Heller theller at python.net
Mon Nov 8 11:35:02 EST 2004


aleaxit at yahoo.com (Alex Martelli) writes:

> Jacek Generowicz <jacek.generowicz at cern.ch> wrote:
>    ...
>> > > > Is there any generic way to use C++ libraries from within Python.
>> > > 
>> > > > Without doing anything else (such as recompiling the library or
>> > > > generating wrappers).
>> > > 
>> > > Bit of a tall order, don't you think?
>> > 
>> > Well, ctypes does that for C libraries (as long as they're
>> > DLL/so/dynlib/...), it's not immediately obvious that using C++
>> > libraries is an order of magnitude harder (though probably true).
>> 
>> Maybe not _immediately_ obvious, but obvious after a few minutes
>> thought :-)
>
> To somebody with a good grasp of the current state of C++ technology,
> maybe.  Somebody who might just like to using existing dynlib/&c which
> happen to be oriented to C++ rather than C might quite reasonably not
> find the distinction obvious, IMHO.
>
> Indeed, I suspect ctypes could be extended to do some of the requested
> task, if one focused on a single, specific C++ compiler.

I guess that MSVC uses the same binary layout for C++ objects as for COM
objects, so it should be possible.  I don't know if the name mangling rules
are documented somewhere.

But I have no idea how inline definitions of member functions (I'm not
sure that's the correct term - I mean code defined in the header files)
should be converted to Python code.

Thomas



More information about the Python-list mailing list