I've read the documentation and coded up my own example based on their Noddy
example:
https://docs.python.org/3.4/extending/newtypes.html
This is a bit of a departure from usingPy_BuildValue()
to build arbitrary objects dynamically. It appears that the underlying assumption is that there’s a C structure backing every object instance you want to create.
Is this really the only (best?) way to create new objects in Python? I was hoping to create a new object and declare members/types similar to how you would create tuples, lists, and dictionaries etc. It seems like it should be possible to declare a new type, declare members and their types, and then plug values in field-by-field w/o all this.
I can't even use the structure defined by the existing API of what I'm gluing because Python objects require the compulsoryPyObject_HEAD
field. I have to define a new C structure, copy the relevant elements that were handed back to me from the API call. It just seems like a level of memory management on the C side that should be unnecessary.