Making immutable instances
Mike Meyer
mwm at mired.org
Wed Nov 23 21:44:33 EST 2005
Ben Finney <bignose+hates-spam at benfinney.id.au> writes:
> Are there other, more dependable, ways of making immutable objects?
Your answer can be found at <URL:
http://www.cs.bgu.ac.il/~omri/Humor/write_in_c.html >
>> 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
behavior.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list