A way to avoid copying update_slot of type_setattro ?

Boris Boutillier boris.boutillier at arteris.net
Tue Nov 4 14:29:29 CET 2003

Hi all,

I'm writing a Python C-Extension module with new classes.
These classes must be setable by the user. As default type setattr
doesn't allow Extension classes to be setable, I have to write a 
specific setattr on my Metaclasses.
The first part of a type setattr is to call PyObject_GenericSetAttr which
is in the API, but next if the user change one of the slot I have to
update slots. And in my case the user can modify slots, it is even
encouraged (I am writing a database for netlist description of electronic
circuit and the use may want that MyNet1 + MyNet2 instantiate a specific
addition module, so he'll have to set a slot, __add__).

The problem is that update_slot is not in the API, and is not easy to copy
paste, so before doing it I'd like to know if someone already got this
problem and found some elegant solution.
One possible python enhancement would be to add a SETABLE_CLASS flag to
python classes, defaulting to 0 (for backward compatibility) and change
the check done in type_setattro, set_bases, set_bases to check for this
flag, not HEAPTYPE, I'll make it, test it and send the patch when I'll
have time for that.

Thanks in advance.


More information about the Python-list mailing list