[Python-Dev] apparent ruminations on mutable immutables (was:PEP 351, the freeze protocol)

Michael Chermside mcherm at mcherm.com
Wed Nov 2 14:48:55 CET 2005

Josiah Carlson writes:
> If you make such a suggestion, I would offer that you create a new PEP,
> because this discussion has gone beyond PEP 351, and has wandered into
> the realm of "What other kinds of objects would be interesting to have
> in a Python-like system?"

Noam Raphael replies:
> That is a good suggestion, and I have already started to write one. It
> takes me a long time, but I hope I will manage.

My thanks to both of you... following this conversation has been an
educational experience. Just for the record, I wanted to chime in with
my own opinion formed after following the full interchange.

I think Noam's propsal is very interesting. I like the idea of allowing
both "frozen" (ie, immutable) and mutable treatments for the same
object. I think that C++'s version of this concept (the "const" modifier)
has, on balance, been only a very limited success. I find myself convinced
by Noam's claims that many common use patterns either (1) only use mutables,
or (2) only use immutables, or (3) only use immutable copies temporarily
and avoid mutating while doing so. Any such use patterns (particularly
use (3)) would benefit from the presence of an efficient method for
creating an immutable copy of a mutable object which avoids the copy where

However... it seems to me that what is being described here is not Python.
Python is a wonderful language, but it has certain characteristics, like
extremely dynamic behavior and close integration with underlying system
methods (C in CPython, Java in Jython, etc) that seem to me to make this
particular feature a poor fit. That's OK... not all languages need to be

I would encourage you (Noam) to go ahead and explore this idea of yours.
You might wind up building a new language from scratch (in which case I
strongly encourage you to borrow _syntax_ from Python -- its syntax is
more usable than that of any other language I know of). Or perhaps you
will prefer to take CPython and make minor modifications. This kind of
experimentation is allowed (open source) and even encouraged... consider
Christian Tismer's Stackless -- a widely admired variant of CPython which
is unlikely to ever become part of the core, but is nevertheless an
important part of the vivrant Python community. You might even be
interested in starting, instead, with PyPy -- an large project which has
as its main goal producing an implementation of Python which is easy
to modify so as to support just this kind of experimentation.

You are also welcome to submit a PEP for modifying Python (presumably
CPython, Jython, Iron Python, and all other implementations). However,
I think such a PEP would be rejected. Building your own thing that
works well with Python would NOT be rejected. The idea is interesting,
and it _may_ be sound; only an actual implementation could prove this
either way.

-- Michael Chermside

More information about the Python-Dev mailing list