Help understanding the decisions *behind* python? - immutable objects
Raymond Hettinger
python at rcn.com
Fri Jul 31 17:55:16 EDT 2009
On Jul 26, 11:24 am, John Nagle <na... at animats.com> wrote:
> A tuple is really a frozen list. Arguably, frozen objects
> should have been a general concept. Conceptually, they're
> simple - once "__init__" has run, there can be no more changes
> to fields of the object.
I would argue that freezing and thawing (making the container
statefull)
is the proverbial road to hell paved with good intentions. It is
roughly in the same category as dynamic scoping -- programs become
harder to analyze for correctness -- code that used to work can
break because something froze it along the way (perhaps to use it
as a key for dict or set in a caching function) or because something
unfroze it (so it could mutate a value).
Raymond
More information about the Python-list
mailing list