Making immutable instances
Ben Finney
bignose+hates-spam at benfinney.id.au
Thu Nov 24 08:26:01 EST 2005
Alex Martelli <aleax at mail.comcast.net> wrote:
> Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> > Why is "I want to make objects immutable" seen as "I don't trust
> > my users"? Are Python's existing immutable types also seen the
> > same way? If not, why the distinction?
>
> A type implemented in C offers different possibilities than one
> implemented in Python -- no deep conceptual reason, just practical
> ones.
So, in the hypothetical situation that all Python types were
implemented in pure Python, what would the ideal behaviour for
immutables be? Or would there be no immutables?
> I don't think that making it explicit that you intended to document
> the restriction would have changed my answer (although an explicit
> acknowlegment that you're looking for restrictions against
> accidental misuse rather than against determined attackers surely
> would).
I'm looking for a "consenting adults" restriction: classes will have
immutable instances only where it makes sense from the class protocol.
I'm not going to lose sleep over users who go looking for trouble.
--
\ "Think for yourselves and let others enjoy the privilege to do |
`\ so too." -- Voltaire, _Essay On Tolerance_ |
_o__) |
Ben Finney
More information about the Python-list
mailing list