From 6add25acb0865e24b9652255af816ba71fa9948d Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Mon, 28 Nov 2016 11:13:39 +0100 Subject: [PATCH] Make all match objects hashable --- loopy/match.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/loopy/match.py b/loopy/match.py index 66cc58cbe..ab0038af8 100644 --- a/loopy/match.py +++ b/loopy/match.py @@ -140,6 +140,9 @@ class All(MatchExpressionBase): def __eq__(self, other): return (type(self) == type(other)) + def __hash__(self): + return hash(type(self)) + class And(MatchExpressionBase): def __init__(self, children): @@ -159,6 +162,9 @@ class And(MatchExpressionBase): return (type(self) == type(other) and self.children == other.children) + def __hash__(self): + return hash((type(self), self.children)) + class Or(MatchExpressionBase): def __init__(self, children): @@ -178,6 +184,9 @@ class Or(MatchExpressionBase): return (type(self) == type(other) and self.children == other.children) + def __hash__(self): + return hash((type(self), self.children)) + class Not(MatchExpressionBase): def __init__(self, child): @@ -197,6 +206,9 @@ class Not(MatchExpressionBase): return (type(self) == type(other) and self.child == other.child) + def __hash__(self): + return hash((type(self), self.child)) + class GlobMatchExpressionBase(MatchExpressionBase): def __init__(self, glob): @@ -218,6 +230,9 @@ class GlobMatchExpressionBase(MatchExpressionBase): return (type(self) == type(other) and self.glob == other.glob) + def __hash__(self): + return hash((type(self), self.glob)) + class Id(GlobMatchExpressionBase): def __call__(self, kernel, matchable): -- GitLab