[capi-sig] Creating type object dynamically in run-time

Mateusz Loskot mateusz at loskot.net
Thu May 10 18:58:24 CEST 2012

On 10 May 2012 17:32, Stefan Behnel <python_capi at behnel.de> wrote:
> Mateusz Loskot, 10.05.2012 15:55:
>> 3)
>> Is there third option possible which replaces the 2nd's type() call
>> with chain of plain Python C API calls?
>> I know there are pros/cons related to amount of code, maintenance hassle,
>> code complexity, and such. but it is not related to my question really.
> I don't know what the best way is here. However, I really wonder what you
> are trying to achieve.

Long story short, I have a software system implemented in C/C++ which
provides public API. The API is not fixed, may change, so scripting
engines use provided means of reflection to inspect this API and
generate bindings on-fly.
I embedded Python in this system and now I'm using the mentioned
reflection mechanisms to discover API and generate Python extension
modules and types dynamically during run-time.

I simply use the reflection mechanisms provided to iterate over
definitions (structures, functions, constants, etc.) of the public API
and I compose Python extension types grouping methods, etc.

I can not use Cython, nor I can use tools like SWIG, Boost.Python.
The (C)Python is the only tool I can use.

Best regards,
Mateusz Loskot, http://mateusz.loskot.net

More information about the capi-sig mailing list