UniqueThing#
- class blueprints.UniqueThing[source]#
Bases:
UniqueThingType,BaseThingThings that have multiple parents and that should not be copied to often can inherit from
UniqueThing. If the attributes of this Thing should be altered for one parent but stay the same for other parents, a copy is created which then can be altered. If the the Thing has only one parent the attributes are instead altered directly. To do this, parents can call the_prepare_for_modification()method passing themselves which returns either a copy of the Thing or the Thing itself which can then be altered.>>> alterable_child = node_thing.unique_thing._prepare_for_modification(node_thing) >>> atterable_child.attr = value
This usecase is important if a Thing is modified often, but contains large amounts of data like
blueprints.cache.MeshCacheto avoid redundant copies.- Parameters:
**kwargs – Keyword arguments are passed to
super().__init__
- freeze#
Setting this attribute freezes the setting of other attributes until it is unset.
- Type:
bool
- classmethod __new__(*args, **kwargs)#