-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The performance modification for CallDecl causes problems for cases where the hashes collide.
This is specifically a problem (for me at least) because for python (or at least CPython, but I was able to reproduce with pypy and ipython) hash(-1) == hash(-2).
I'm not sure if there are more problematic edge-cases but this specifically is causing problems for my use case.
from egglog import *
class Num(Expr):
def __init__(self, value: i64Like) -> None: ...
egraph = EGraph()
expr1 = egraph.let("expr1", Num(-1))
expr2 = egraph.let("expr2", Num(-2))
egraph.check(eq(expr1).to(expr2))
print(egraph.extract(expr1))
print(egraph.extract(expr2))Will not find a problem with the equality and print Num(-1) for both (which leads to wrong equalities).
seems to be the problematic code and replacing it with the unoptimized variant fixes the problem.
def __eq__(self, other: object) -> bool:
if not isinstance(other, egglog.declarations.CallDecl):
return False
return self.callable == other.callable and self.args == other.args and self.bound_tp_params == other.bound_tp_paramsUndoing the optimization obviously has a performance impact so I'm not sure if just changing it like this is ideal though.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working