Jack Jansen wrote:
In the discussion on my request for an ("O@", typeobject, void **) format for PyArg_Parse and Py_BuildValue MAL suggested
Thomas Heller suggested this.
I am more in favour of exposing the pickle reduce API through "O@", that is have PyArgTuple_Parse() call the .__reduce__() method of the object. This will then return (factory, state_tuple) and these could then be exposed to the C function via two PyObject*.
Note that there's no need for any type object magic. If this becomes a common case, it may be worthwhile to add a tp_reduce slot to type objects though.