[Python-Dev] PEP 351, the freeze protocol

Josiah Carlson jcarlson at uci.edu
Mon Oct 24 04:50:47 CEST 2005


Barry Warsaw <barry at python.org> wrote:
> I've had this PEP laying around for quite a few months.  It was inspired
> by some code we'd written which wanted to be able to get immutable
> versions of arbitrary objects.  I've finally finished the PEP, uploaded
> a sample patch (albeit a bit incomplete), and I'm posting it here to see
> if there is any interest.
> 
> http://www.python.org/peps/pep-0351.html



    class xlist(list):
        def __freeze__(self):
            return tuple(self)

Shouldn't that be:

    class xlist(list):
        def __freeze__(self):
            return tuple(map(freeze, self))


"Should dicts and sets automatically freeze their mutable keys?"

Dictionaries don't have mutable keys, but it is of my opinion that a
container which is frozen should have its contents frozen as well.

 - Josiah



More information about the Python-Dev mailing list