Making immutable instances

Mike Meyer mwm at
Thu Nov 24 03:44:33 CET 2005

Ben Finney <bignose+hates-spam at> writes:
> Are there other, more dependable, ways of making immutable objects?

Your answer can be found at <URL: >

>> I'm curious as to why you care if people add attributes to your
>> "immutable" class. Personally, I consider that instances of types
>> don't let me add attributes to be a wart.
> I refer you to a similar question: do you consider it a wart that you
> can't add attributes to instances of Python's built-in types?

Didn't I just say that I thought it was a wart?

> Is this a wart? Why?

Because it means I have to wrap them to if I want a typefoo with an
extra attribute. I don't have to do that for classes. It makes builtin
types different from user-defined classes in ways other than
performance, which is a bad thing.

> If it's not a wart, why would it be a wart for user-defined types to
> have the same behaviour?

It's a wart because user-defined classes *don't* have the same

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list