The future of Python immutability
gagsl-py2 at yahoo.com.ar
Fri Sep 4 00:38:05 CEST 2009
En Thu, 03 Sep 2009 15:03:13 -0300, John Nagle <nagle at animats.com>
> Python's concept of immutability is useful, but it could be more
> Immutability is interesting for threaded programs, because
> immutable objects can be shared without risk. Consider a programming
> model where objects shared between threads must be either immutable or
> "synchronized" in the sense that Java uses the term. Such programs
> are free of most race conditions, without much programmer effort to
> make them so.
In the current CPython implementation, every object has a reference count,
even immutable ones. This must be a writable field - and here you have
your race condition, even for immutable objects.
More information about the Python-list