immutable¶
-
lsst.daf.butler.core.utils.immutable(cls)¶ A class decorator that simulates a simple form of immutability for the decorated class.
A class decorated as
immutablemay only set each of its attributes once (by convention, in__new__); any attempts to set an already-set attribute will raiseAttributeError.Because this behavior interferes with the default implementation for the
pickleandcopymodules,immutableprovides implementations of__getstate__and__setstate__that override this behavior. Immutable classes can them implement pickle/copy via__getnewargs__only (other approaches such as__reduce__and__deepcopy__may also be used).