In my brave and noble quest to get to grips with the CAPI - I am trying to write a C extension module which provides a new class

The exact details are not important, but what is important is that instances of my new class are imutable, and therefore from time to time, my extension module needs to build a new instance of my extension class.

The documentation is pretty sparse here, and suggests using PyObject_New & PyObject_Init but gives no examples.

An internet search suggests using PyObject_CallObject in some way - but the examples here are call backs to Python functions.

What is the canonical way to create New Instances of the Extension Type from within the Extension Module - even if someone can point me to a working example that would be great.

Another option would be to call the extension class new and init functions directly - is there a reason that is not allowed ?

PS - I think I also need to use Py_BuildValue to 'encapsulate' the initial arguments for the new instance - or could I just build a 'blank' instance and then directly set the fields as neccessary ?

--
Anthony Flury
*Email* : anthony.fl...@btinternet.com <mailto:anthony.fl...@btinternet.com>
*Twitter* : @TonyFlury <https://twitter.com/TonyFlury/>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to