PEP idea. ( removing __slots__ )

"Martin v. Löwis" martin at v.loewis.de
Sun Jul 6 03:07:14 EDT 2003


simon place wrote:


> To do this nicely requires the renaming of  __dict__ to, say, 
> __attribs__ , ( since dict is unnecessarily unspecific, this seem like a 
> small improvement in itself. ) then using the setting of __attribs__ to 
> a non-mutable type (ie  tuple of attribute names)  to indicate the 
> behaviour of __slots__, rendering it unnecessary, this I think is a good 
> simplification.

That does not work. __slots__ must be set at creation time of the class,
not at creation time of the instance. In your approach, it appears that
__attribs__ would be set, say, in __init__.

If you meant that __attribs__ would be set to the tuple of attribute 
names inside the class definition directly, it appears that you have
renamed __slots__ to __attribs__, which is pointless.

Regards,
Martin





More information about the Python-list mailing list