[Python-Dev] Extending types in C - help needed

Jack Jansen Jack.Jansen@oratrix.nl
Thu, 17 Jan 2002 21:59:13 +0100


On Thursday, January 17, 2002, at 11:29  AM, M.-A. Lemburg wrote:

> 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.

Oops, you're right. I should be careful not to mix up my Germans;-)

> 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*.

You've suggested this before, but at that time I ignored it 
because it made absolutely no sense to me. "pickle" triggers one 
set of ideas for me, "reduce" triggers a different set, "factory 
function" yet another different set. None of these sets of ideas 
have the least resemblance to what I'm trying to do:-)

I gave a fairly complete example (using calldll from Python to 
wrap a function that returns a Mac WindowObject) last week, 
could you explain how you would implement this with pickle, 
reduce and factory functions?
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- 
Emma Goldman -