[Python-Dev] Making mutable objects readonly
Tim Peters
tim.one@home.com
Mon, 29 Jan 2001 21:57:59 -0500
[Guido]
> Yes, this is a good thing. Easy to do on lists and dicts. Questions:
>
> - How to spell it? x.freeze()? x.readonly()?
See below.
> - Should this reversible?
Of course. Or x.freeze(solid=1) to default to permanent rigidity, but not
require it.
> I.e. should there be an x.unfreeze()?
That conveniently answers the first question, since x.unreadonly() reads
horribly <wink>.
> - Should we support something like this for instances too? Sometimes
> it might be cool to be able to freeze changing attribute values...
"Should be" supported for every mutable object. Next step: as in endless
C++ debates, endless Python debates about "representation freeze" vs
"logical freeze" ("well, yes, I'm changing this member, but it's just an
invisible cache so I *should* be able to tag the object as const anyway
..."; etc etc etc).
keep-it-simple-ly y'rs - tim