Suppose I want to have some of my classes be immutable, there is no simple way to do this in python. I can perhaps do something like this:
class MyImmutable: def __setattr__(self, key, value): raise TypeError
or perhaps I can inherit from an immutable type like so
class MyImmutable(namedtuple('Immutable', 'foo bar')): def __setitem__(self, item, value): raise TypeError ...
but I would have to do this for every immutable class, which becomes complicated. It would be nicer if there was something like an abc.Immutable abstract class specifically for creating immutable classes. Then the any class that I want to be strictly immutable can be defined as:
class MyImmutable(abc.Immutable): ...
with no need to override all the setter methods. This would also allow for optimizations of immutable subclasses in memory and performance similar to builtin immutable types.