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

Jack Jansen Jack.Jansen@oratrix.nl
Sat, 19 Jan 2002 01:07:56 +0100


On Friday, January 18, 2002, at 08:36  PM, Martin v. Loewis wrote:

>> Also, the method seems rather complicated for doing a simple 
>> thing. The
>> only thing I really want is a way to refer to an _New or 
>> _Convert method
>> from Python code.
>
> I believe the attached code implements your requirements.
>

Martin, hats off!

This does exactly what I want, and it does so in a pretty 
generalized way. Actually in _such_ a generalized way that I 
think this should be documented loud and clear.

Looking at it a bit more, how about storing each function 
pointer in a separate PyCObject, and adding general APIs 
somewhere in the core
void PyType_SetAnnotation(PyTypeObject *tp, char *name, char 
*descr, void *);
void *PyType_GetAnnotation(PyTypeObject *tp, char *name, char *descr);

(I've picked the name annotation here, because it sort-of feels 
like that, another name may bring the idea across better).
> --
- 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 -