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 raise- AttributeError.- Because this behavior interferes with the default implementation for the - pickleand- copymodules,- 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).