From dac08eb2819a652384869f5685cd4996e631c68b Mon Sep 17 00:00:00 2001 From: Parker Jones Date: Tue, 29 Jul 2025 13:23:35 -0400 Subject: [PATCH 1/3] Add __slots__ entries. --- src/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index c749e6b8f..ffb10d8c2 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -10785,7 +10785,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,7 +10972,7 @@ def unit(self): class Quad: - + __slots__ = ("ul", "ur", "ll", "lr") def __abs__(self): if self.is_empty: return 0.0 @@ -11036,6 +11036,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 +11205,7 @@ 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,7 +12648,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() From f36171403785e6db7c78e14d49bda0c69df69711 Mon Sep 17 00:00:00 2001 From: Parker Jones Date: Fri, 15 Aug 2025 20:40:16 -0400 Subject: [PATCH 2/3] Add `__slots__` entry to Matrix --- src/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__init__.py b/src/__init__.py index ffb10d8c2..52279cbc5 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6686,7 +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])) From 159312cccb65794473645718730d5310f8c5960c Mon Sep 17 00:00:00 2001 From: Parker Jones Date: Mon, 25 Aug 2025 15:29:38 -0400 Subject: [PATCH 3/3] Fix IdentityMatrix __setattrs__, and cleanup whitespaces. --- src/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index 52279cbc5..e16ca7584 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -6687,6 +6687,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") @@ -10786,6 +10788,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) @@ -10973,6 +10976,7 @@ def unit(self): class Quad: __slots__ = ("ul", "ur", "ll", "lr") + def __abs__(self): if self.is_empty: return 0.0 @@ -11206,6 +11210,7 @@ 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 @@ -12649,6 +12654,7 @@ class IRect: IRect(sequ) - new from sequence or rect-like """ __slots__ = ("x0", "y0", "x1", "y1") + def __add__(self, p): return Rect.__add__(self, p).round()