Wouldn't it be just as future-proof to make __slots__ a list of bare slot names or objects? One advantage is that slot names don't have to be carried around externally to the objects. Moreover, using standard attribute names like __name__ and __doc__ will make the solution more future-proof.
The default metaclass will handle __slots__ along these lines:
for item in obj.__slots__: if isinstance(item, StringTypes): slot_name, slot_doc = item, None else: slot_name = item.__name__ slot_doc = getattr(item, '__doc__', None)
In that way, the default metaclass does not impose any restrictions on what the slot objects are.
class MySlot(object): def __init__(self, name, doc=None): self.__name__ = name self.__doc__ = doc class C(object): __slots__ = ['slot1', MySlot('slot2', 'this is the docstring')]
I am still very interested in seeing this happen. I'm looking for a Python C API expert who would be kind enough to get me started with the necessary mods to the default Python metaclass.
I already have a prototype of the pydoc improvements which go hand-in-hand with this change (http://sourceforge.net/tracker/index.php?func=detail&aid=936774&grou...).