The future of Python immutability

Bearophile bearophileHUGS at lycos.com
Sun Sep 6 15:39:01 CEST 2009


John Nagle:
> The concept here is that objects have an "owner", which is either
> a thread or some synchronized object.   Locking is at the "owner"
> level.  This is simple until "ownership" needs to be transferred.
> Can this be made to work in a Pythonic way, without explicit
> syntax?
>
> What we want to happen, somehow, is to
> transfer the ownership of "words" from the calling thread to the object
> in "putitem", and transfer it to the calling thread in "getitem".
> How can this be done?

There are several people that have found ways to implement such owning
of variables, for example Bartosz Milewski:

http://bartoszmilewski.wordpress.com/2009/06/02/race-free-multithreading-ownership/

It requires some extra complexities, so statically typed languages
usually don't implement this idea, even if it avoids bugs in user
code.
Implementing it in Python in a simple enough way looks like a good
topic for advanced research :-)

Bye,
bearophile



More information about the Python-list mailing list