[Python-Dev] slots, properties, descriptors, and pydoc (original) (raw)

Fred L. Drake, Jr. fdrake at acm.org
Sun Apr 18 11:55:30 EDT 2004


On Sunday 18 April 2004 11:35 am, John Belmonte wrote:

I'm concerned about something though. Doesn't this implementation impose an overhead on access of slots with doc strings, or can a C implementation be made just as efficient as normal slots?

This implementation does, but a C implementation in the core could avoid that easily enough. It may even be that this could be avoided using a Python implementation by generating an slots that isn't munged so heavily and then playing metaclass tricks to cause the docstrings to be inserted directly on the descriptors generated by the current slots machinery.

I wasn't too worried about that for the example code, but you're certainly free to construct something that suits you. I think it would be more interesting to create slot-based properties without the renaming currently needed, but I'm not sure how to do that off-hand. If the slot property type were available for subclassing it would be pretty easy, I'd hope.

I'm also wondering about Guido's comment. Even if the slots handler were extended to handle docstrings directly via dict values, wouldn't metaclasses still be free to intercept the dict for other uses?

Metaclasses can do what they want to affect the new type. That's what they're for.

-Fred

-- Fred L. Drake, Jr. PythonLabs at Zope Corporation



More information about the Python-Dev mailing list