Python dynamic attribute creation

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Jun 25 17:11:31 EDT 2010


On 25/06/2010 19:23, WANG Cong wrote:
> On 06/25/10 14:31, Richard Thomas<chardster at gmail.com>  wrote:
>
> <snip>
>
>>
>> If you desperately want to limit the attribute assignments that can be
>> performed on an object you can set the __slots__ attribute of its
>> type. However, the Python ethos has always been to restrict as little
>> as necessary to provide the tools it needs. Performing additional
>> checks every time an attribute assignment is performed is completely
>> unnecessary. Remember that unlike C these checks would have to be
>> performed at run-time.
>>
>
> I don't care in which way I can limit this, I care why I should limit
> this by default, not vice versa?
>
> Yeah, I do understand this could be a performance issue, but comparing
> it with a language design issue, _I think_ the latter thing is much more
> important than the former one.
>

Blimey, one minute we're talking about "Python dynamic attribute 
creation", the next it's a performance issue.  What do you want, blood 
on it?

Kindest regards.

Mark Lawrence.




More information about the Python-list mailing list