[Python-Dev] Need advice, maybe support (original) (raw)

Martin v. L�wis martin@v.loewis.de
19 May 2003 22:10:45 +0200


Christian Tismer <tismer@tismer.com> writes:

The problem is that I need to give extra semantics to existing objects, which are PyCFunction objects. I think putting an extra bit into the type object doesn't help, unless I use a new type. But then I don't need the flag. An old extension module which is loaded into my Python will always use my PyCFunction, since this is always borrowed.

I understand the concern is not about changing PyCFunction, but about changing PyMethodDef, which would get another field.

I think you can avoid adding a field to PyMethodDef, by providing a PyMethodDefEx structure, which has the extra field, and is referred-to from (a new slot in) the type object. The slots in the type object that refer to PyMethodDefs would either get set to NULL, or initialized with a copy of the PyMethodDefEx with the extra field removed.

Regards, Martin