Barry Warsaw 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
I think it's definitely worth considering. It may also reduce the need for "x" and "frozenx" builtin pairs. We already have "set" and "frozenset", and the various "bytes" ideas that have been kicked around have generally considered the need for a "frozenbytes" as well. If freeze was available, then "freeze(x(*args))" might server as a replacement for any builtin "frozen" variants. I think having dicts and sets automatically invoke freeze would be a mistake, because at least one of the following two cases would behave unexpectedly: d = {} l = [] d[l] = "Oops!" d[l] # Raises KeyError if freeze() isn't also invoked in __getitem__ d = {} l = [] d[l] = "Oops!" l.append(1) d[l] # Raises KeyError regardless Oh, and the PEP's xdict example is even more broken than the PEP implies, because two imdicts which compare equal (same contents) may not hash equal (different id's). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.blogspot.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com