[Python-ideas] Support other dict types for type.__dict__

Simon Sapin simon.sapin at kozea.fr
Sun Feb 26 17:51:08 CET 2012

Le 26/02/2012 14:56, Victor Stinner a écrit :
> type.__setattr__(Three, 'value', 4) changes the value.

Then there is the question of how much craziness you want to protect 
from. Nothing is ever truly private or immutable in CPython, given 
enough motivation and ctypes.

See for example Armin Ronacher’s "Bad Ideas" presentation, especially 
the "Interpreter Warfare" part near the end:


I think that the code patching tracebacks is in production in Jinja2. 
I’m sure frozensets could be modified in a similar way.

The point is: immutable data types protect against mistakes more than 
someone truly determined to break the rules. With that in mind, I think 
that having to go through __setattr__ is good enough to make sure it’s 
not accidental.

Simon Sapin

More information about the Python-ideas mailing list