diff --git a/src/__init__.py b/src/__init__.py index c749e6b8f..e16ca7584 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6686,6 +6686,7 @@ def uri(self): class Matrix: + __slots__ = ("a", "b", "c", "d", "e", "f", ) def __abs__(self): return math.sqrt(sum([c*c for c in self])) @@ -6929,6 +6930,7 @@ def pretranslate(self, tx, ty): class IdentityMatrix(Matrix): """Identity matrix [1, 0, 0, 1, 0, 0]""" + __slots__ = ("a", "b", "c", "d", "e", "f", ) def __hash__(self): return hash((1,0,0,1,0,0)) @@ -6939,13 +6941,13 @@ def __init__(self): def __repr__(self): return "IdentityMatrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)" - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: float): if name in "ad": - self.__dict__[name] = 1.0 + object.__setattr__(self, name, 1.0) elif name in "bcef": - self.__dict__[name] = 0.0 + object.__setattr__(self, name, 0.0) else: - self.__dict__[name] = value + raise ValueError(f"Expected one of 'abcdef', got {name} = {value}") def checkargs(*args): raise NotImplementedError("Identity is readonly") @@ -10785,6 +10787,7 @@ def __del__(self): del Point class Point: + __slots__ = ("x", "y") def __abs__(self): return math.sqrt(self.x * self.x + self.y * self.y) @@ -10972,6 +10975,7 @@ def unit(self): class Quad: + __slots__ = ("ul", "ur", "ll", "lr") def __abs__(self): if self.is_empty: @@ -11036,6 +11040,7 @@ def __init__(self, *args, ul=None, ur=None, ll=None, lr=None): None. ''' + if not args: self.ul = self.ur = self.ll = self.lr = Point() elif len(args) > 4: @@ -11204,7 +11209,8 @@ def transform(self, m): class Rect: - + __slots__ = ("x0", "y0", "x1", "y1") + def __abs__(self): if self.is_empty or self.is_infinite: return 0.0 @@ -12647,6 +12653,7 @@ class IRect: IRect(top-left, bottom-right) - 2 points IRect(sequ) - new from sequence or rect-like """ + __slots__ = ("x0", "y0", "x1", "y1") def __add__(self, p): return Rect.__add__(self, p).round()