Extension Module for Python 3.6 +
anthony.flury at btinternet.com
Thu Feb 28 20:19:04 EST 2019
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 ?
*Email* : anthony.flury at btinternet.com <mailto:Anthony.flury at btinternet.com>
*Twitter* : @TonyFlury <https://twitter.com/TonyFlury/>
More information about the Python-list