From c107e7b2e74b995447325dbd63c9da90c580a1ca Mon Sep 17 00:00:00 2001 From: Leeky Date: Fri, 20 Dec 2024 10:57:02 +0100 Subject: [PATCH 1/6] Added required version field to pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 69c6c39e..86058481 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ build-backend = "maturin" name = "egglog" description = "e-graphs in Python built around the the egglog rust library" readme = "README.md" +dynamic = ["version"] license = { text = "MIT" } requires-python = ">=3.10" classifiers = [ From 52e85e9746d63bfed2b0353b5b196e1cc227b9c3 Mon Sep 17 00:00:00 2001 From: Leeky Date: Fri, 20 Dec 2024 11:23:38 +0100 Subject: [PATCH 2/6] Undoing optimization CallDecl __eq__ --- python/egglog/declarations.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/egglog/declarations.py b/python/egglog/declarations.py index 86ad479f..73f4e6f9 100644 --- a/python/egglog/declarations.py +++ b/python/egglog/declarations.py @@ -570,10 +570,9 @@ def _cached_hash(self) -> int: return hash((self.callable, self.args, self.bound_tp_params)) def __eq__(self, other: object) -> bool: - # Override eq to use cached hash for perf - if not isinstance(other, CallDecl): + if not isinstance(other, egglog.declarations.CallDecl): return False - return hash(self) == hash(other) + return self.callable == other.callable and self.args == other.args and self.bound_tp_params == other.bound_tp_params @dataclass(frozen=True) From 5655c2ff1638eff8fc82675bdb0280435ad2b7e4 Mon Sep 17 00:00:00 2001 From: Leeky Date: Fri, 20 Dec 2024 11:32:11 +0100 Subject: [PATCH 3/6] Copied wrong line --- python/egglog/declarations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/egglog/declarations.py b/python/egglog/declarations.py index 73f4e6f9..e9ddea2c 100644 --- a/python/egglog/declarations.py +++ b/python/egglog/declarations.py @@ -570,7 +570,7 @@ def _cached_hash(self) -> int: return hash((self.callable, self.args, self.bound_tp_params)) def __eq__(self, other: object) -> bool: - if not isinstance(other, egglog.declarations.CallDecl): + if not isinstance(other, CallDecl): return False return self.callable == other.callable and self.args == other.args and self.bound_tp_params == other.bound_tp_params From 61ee2eaa65766025a23b8fb03444cc56eb134c7c Mon Sep 17 00:00:00 2001 From: Leeky Date: Fri, 20 Dec 2024 11:45:22 +0100 Subject: [PATCH 4/6] Partial Optimization --- python/egglog/declarations.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/egglog/declarations.py b/python/egglog/declarations.py index e9ddea2c..1515fef2 100644 --- a/python/egglog/declarations.py +++ b/python/egglog/declarations.py @@ -570,11 +570,15 @@ def _cached_hash(self) -> int: return hash((self.callable, self.args, self.bound_tp_params)) def __eq__(self, other: object) -> bool: + # Override eq to use cached hash for perf if not isinstance(other, CallDecl): return False + if hash(self) != hash(other): + return False return self.callable == other.callable and self.args == other.args and self.bound_tp_params == other.bound_tp_params + @dataclass(frozen=True) class PartialCallDecl: """ From 49e0c01c57131673d6ccce9887b0b3031e410e50 Mon Sep 17 00:00:00 2001 From: Leeky Date: Fri, 20 Dec 2024 12:11:20 +0100 Subject: [PATCH 5/6] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 86058481..4ec43c36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "maturin" name = "egglog" description = "e-graphs in Python built around the the egglog rust library" readme = "README.md" -dynamic = ["version"] +dynamic = ["version"] license = { text = "MIT" } requires-python = ">=3.10" classifiers = [ From c0a1565b198b8c0ad3bd56af8d337dc27e98565e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:11:29 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- python/egglog/declarations.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/egglog/declarations.py b/python/egglog/declarations.py index 1515fef2..f55a599f 100644 --- a/python/egglog/declarations.py +++ b/python/egglog/declarations.py @@ -575,8 +575,11 @@ def __eq__(self, other: object) -> bool: return False if hash(self) != hash(other): return False - return self.callable == other.callable and self.args == other.args and self.bound_tp_params == other.bound_tp_params - + return ( + self.callable == other.callable + and self.args == other.args + and self.bound_tp_params == other.bound_tp_params + ) @dataclass(frozen=True)