Custom deepcopy() implementations to help speed things up

This commit is contained in:
Jan Petykiewicz 2019-05-15 00:19:37 -07:00
commit a461446059
9 changed files with 80 additions and 8 deletions

View file

@ -3,7 +3,7 @@
offset, rotation, scaling, and other such properties to the reference.
"""
from typing import Union, List
from typing import Union, List, Dict
import copy
import numpy
@ -45,6 +45,14 @@ class SubPattern:
mirrored = [False, False]
self.mirrored = mirrored
def __deepcopy__(self, memo: Dict = None) -> 'SubPattern':
memo = {} if memo is None else memo
new = copy.copy(self)
new.pattern = copy.deepcopy(self.pattern, memo)
new._offset = self._offset.copy()
new._mirrored = copy.deepcopy(self._mirrored, memo)
return new
# offset property
@property
def offset(self) -> numpy.ndarray: