Only swap between tuple/list if actually necessary

This commit is contained in:
Jan Petykiewicz 2020-05-23 19:39:48 -07:00
parent 07ee25e735
commit 53d2a9ca1a

View File

@ -764,10 +764,11 @@ class Pattern:
Returns: Returns:
self self
""" """
self.shapes = tuple(self.shapes) if not self.locked:
self.labels = tuple(self.labels) self.shapes = tuple(self.shapes)
self.subpatterns = tuple(self.subpatterns) self.labels = tuple(self.labels)
object.__setattr__(self, 'locked', True) self.subpatterns = tuple(self.subpatterns)
object.__setattr__(self, 'locked', True)
return self return self
def unlock(self) -> 'Pattern': def unlock(self) -> 'Pattern':
@ -777,10 +778,11 @@ class Pattern:
Returns: Returns:
self self
""" """
object.__setattr__(self, 'locked', False) if self.locked:
self.shapes = list(self.shapes) object.__setattr__(self, 'locked', False)
self.labels = list(self.labels) self.shapes = list(self.shapes)
self.subpatterns = list(self.subpatterns) self.labels = list(self.labels)
self.subpatterns = list(self.subpatterns)
return self return self
def deeplock(self) -> 'Pattern': def deeplock(self) -> 'Pattern':