Lawful != Mutable (was Can Python function return multiple data?)

Ron Adam ron3200 at gmail.com
Sun Jun 21 08:55:53 EDT 2015



On 06/20/2015 10:50 PM, Rustom Mody wrote:
> Here is Eric Snow:
>
> | Keep in mind that by "immutability" I'm talking about*really*
> | immutable, perhaps going so far as treating the full memory space
> | associated with an object as frozen.  For instance, we'd have to
> | ensure that "immutable" Python objects like strings, ints, and tuples
> | do not change (i.e. via the C API).  The contents of involved
> | tuples/containers would have to be likewise immutable.  Even changing
> | refcounts could be too much, hence the idea of moving refcounts out to
> | a separate table.
> |
> | This level of immutability would be something new to Python.  We'll
> | see if it's necessary.  If it isn't too much work it might be a good
> | idea regardless of the multi-core proposal.
>
> Does the second para look like CPython implementation or python-the-language?
>
> Also note the 'Even' in the first para. ie Eric is talking of low-level
> (ie thread-safety, refcounting etc) immutability after the even and higher
> level semantic immutability before

It seems to me, this will take a lot more changes to python overall.

Adding a way to raise an exception if an object is mutated would be a good 
initial step.  Have it turned off by default.

I think it will be needed to test how any of the above is working.

It may also allow some multiprocessing just by avoiding raising any 
MutatedObject exceptions.

Cheers,
    Ron




More information about the Python-list mailing list